|
Putting out a block of text: $onput, $offput, $onputs, $onputv |
Top Previous Next |
|
Sometimes one needs to put out several lines of text just for appearances sake. In such a case using conventional puts one would have syntax like the following (putex12.gms)
Put 'Line 1 of text' /; Put 'Line 2 of text' //; Put 'Line 3 of text' /; Put 'Line 4 of text' /;
One may use the commands $onput and $offput as an alternative
$onput Line 1 of text Line 2 of text
Line 3 of text Line 4 of text $offput
Yielding idenetical put files. In this case the text block is begun with $onput and ended with $offput. There is also a variant, 2, that uses substitutable parameters (Parameter substitution is discussed in the Conditional Compilation chapter). Namely $onputs will cause all parameter statements in it (those enclosed in % signs) to be replaced with any defined GAMS calling parameters of control variables. $onputv suppresses any substitution. For example the sequence (putex12.gms)
$setglobal it "from $onputs" $onputs substitution Line 1 of text "%it%" Line 2 of text %it% Line 3 of text %it% Line 4 of text %it% $offput
Generates the output
substitution Line 1 of text "from $onputs" Line 2 of text from $onputs Line 3 of text from $onputs Line 4 of text from $onputs
While (putex12.gms)
$setglobal it "from $onputs" $onputv No substitution Line 1 of text "%it%" Line 2 of text %it% Line 3 of text %it% Line 4 of text %it% $offput
Generates
No substitution Line 1 of text "%it%" Line 2 of text %it% Line 3 of text %it% Line 4 of text %it% |