In line comments

Top  Previous  Next

Comments may be included intermixed with instructions in a line of GAMS code.  This involves both activation and specification.

Activation -- while GAMS accommodates such statements it must be told to do so.  This is done by using the command $Oninline.
Specification -- in line comments are set off through the entry of the character string /* before the comment and */ after the string which renders all the characters within these delimiters as a comment.
Activating characters can be changed with the command $inlinecom.

Example:

(commentdol.gms)

$oninline

x=x      /* in line comment*/ +1;

x = x  /* in line comment in line 

          that continues on */

   +1;

$inlinecom /&  &/

x=x      /& eol comment with new character &/ +1;

Notes:

Before in line comments can be used a $Oninline activating statement must appear.
In line comments must be set off before and after with the initiating (/*) and terminating delimiters (*/).
In line comments are copied through to the echo print listing on the appropriate lines.
The lines in which in line comments appear must be fully valid GAMS statements, but the comment can appear on intermediate lines of a statement that terminates later.
In line comments once begun may span multiple lines before the terminating character appears.
The ability to add an in line comment can be terminated by entering the command $Offinline.
One can redefine the initiating and terminating characters from /* and */ to some other choice using the command $Inlinecom cc dd where cc and dd are the new delimiting character strings designating beginning and end of a comment as illustrated above.Inline comments may be allowed to be nested using $Onnestcom.