Page 1 of 1

dollar sign ($) in macro

Posted: Thu Apr 30, 2020 12:55 pm
by Jarenka
Dear,

I have a question concerning $macro statement, where I want to use '$call' option. For example:

Code: Select all

$macro create(VARnam) $call gdxdump %Filaname%.gdx output=%Path%&VARnam.csv symb=&VARnam %SpecKey%
create(xaf_mat)
Everything seems wokring except the

Code: Select all

$call
option. I was trying to find, how the problem with dollar sign should be treated in macro statement, but I couldn't find it.
Do you have any hint to help me.

The macro I am presentating here is creating csv files. I have to create over 200 such files.

Best
Irena

Re: dollar sign ($) in macro

Posted: Fri May 01, 2020 7:08 am
by bussieck
Macros are expanded by the GAMS compiler. The expanded text is not scanned for compile time commands (anything that starts with a $, like $call) by the compiler, so you can't have a $ command inside a macro. You will need to use a batinclude for this:

Code: Select all

$set Filaname xxx
$set Path  abc/
$set SpecKey
$escape &
$echo $call gdxdump %Filaname%.gdx output=%Path%%&1.csv symb=%&1 %SpecKey% > create.gms
$escape %
* Now use it
$batinclude create xaf_mat
-Michael

Re: dollar sign ($) in macro

Posted: Sat May 02, 2020 9:14 am
by Raga
Dear;
Yes you can use $ instead of $call