Multiple line comments

Top  Previous  Next

While one can enter a series of comments beginning with an * in column 1, there are cases where it is most convenient to incorporate a multi line text comment without the need for an * in each line.  This is done by using the paired $ commands $Ontext and $Offtext. $Ontext causes all lines after it to be treated as comments regardless of content. $Offtext terminates the comment begun by a $Ontext making subsequent lines regular GAMS statements.  The lines in between constitute the comment.

Example:

(commentdol.gms)

$ontext

Here is a file showing how to use

various types of comments

 

valid GAMS statements can also be in the

comment but will not be compiled

 

set a /1*11/;

$offtext

set a /a1,a2/;

set b /a2,c2/

set c /a3,d3/;

Notes:

Lines in the $ontext $offtext sequence are copied through to the echo print listing but without line numbers.
These items can be used to rapidly deactivate large sections of code that one does not wish to execute or compile as in speed or memory use searches.