$Call

Top  Previous  Next

The $Call is a dollar command as explained in the Dollar Commands chapter.  This command uses the syntax

 

$Call commandtoexecuteinOS

or

$Call =commandtoexecuteinOS

 

to execute a program or operating system command specified by commandtoexecuteinOS during compilation and before the inclusion of any subsequent include statements.  This halts compilation until the operating system indicates that file has been run (Note the = may be needed to make this always be true as explained in the Notes section below).  One can create a file in the external program and then use an Include command to bring in that file within the current GAMS program.

Exampes:

(xlimport.gms)

$Call is used in Rutherford's spreadsheet interface Xlimport program.  In the current version, two external programs are used.  Namely Gdxxrw is used via a $call to get data out of a spreadsheet and Xldump is used also via a $call to read the GDX data and convert it into a GAMS readable format in the file xllink.in then those data are immediately included into the GAMS program permitting range checking.

 

$call Gdxxrw "%XLS%" @xllink.txt log=xllink.log

 

* If filtered import, read from GDX

$if %more% == '' $goto unfiltered

$GDXin xllink.gdx

$load %sym%

$GDXin

$goto term

 

$label unfiltered

$onempty

$if ParType  %sym% parameter %sym% /

$if SetType  %sym% set %sym% /

$call GDXdump xllink.gdx symb=%sym% noheader > xllink.in

$include xllink.in

Notes:

Generally GAMS will pause until the external job is completed so the next statement after the $Call can use the GAMS include syntax to incorporate any files created by running the external program.
The other commands in this sequence are explained in the Conditional Compilation or Dollar Commands chapters.
In some applications the $Call statement needs to include an = before the name of the program called as follows.

 

 $call =XLS2gms "i=c:\my documents\test.xls" o=d:\tmp\test.inc

 

 This may be required to make GAMS wait until a program is finished.  This will be needed for programs that are true windows applications.  One can see if this is the case by running a program from the DOS command prompt.  If control is returned to the command prompt before the program is finished then the = is needed.  A technical explanation of why this is necessary can be found in the Xls2gms section of http://www.gams.com/interface/interface.html.