Loop through Compile Time Variables using $set

I would like to loop through a set of Compile Time Variables without repeatedly redefining their content using the $set option.

For example, i have the following code.

$set A 123
Execute ‘gams %GAMS_Model% --DataPath=%A%’;

$set A 456
Execute ‘gams %GAMS_Model% --DataPath=%A%’;

$set A 789
Execute ‘gams %GAMS_Model% --DataPath=%A%’;

I have nearly 1000 such Datapaths. Is there a way to loop through all 1,000 values, without typing 2,000 lines of code?

Any suggestions are appreciated.

It seems that you use the CTV for writing different file names. The varying file name part seems to be relatively simple (in your example a number). I would do this with a driving set and the put_utility ‘exec’ all at run-time:

set run / 123, 465, 789 /;
loop(run,
  put_utility 'exec' / 'gams %GAMS_Model% --DataPath=' run.tl:0;
);

Search the forum for put_utility and you will find many similar topics.

-Michael