dollar sign ($) in macro

Problems with syntax of GAMS
Post Reply
Jarenka
User
User
Posts: 59
Joined: 1 year ago

dollar sign ($) in macro

Post by Jarenka » 1 month ago

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

User avatar
bussieck
Moderator
Moderator
Posts: 465
Joined: 3 years ago

Re: dollar sign ($) in macro

Post by bussieck » 1 month ago

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

Raga
User
User
Posts: 3
Joined: 1 month ago

Re: dollar sign ($) in macro

Post by Raga » 1 month ago

Dear;
Yes you can use $ instead of $call

Post Reply