Skip to a specified row: #

Top  Previous  Next

When GAMS encounters a # in a put statement the writing position is moved to that row of the output file whether it be down or up from the current line.  The file putex4.gms shows an example

 

Put #3 'Hello#2 'Goodbye#1 'Hey these are reversed';

 

which would yield

 

            Hey these are reversed

     Goodbye

Hello

Notes:

The above uses of #1 shows how one can go back and write earlier lines.
One can use variables or expressions instead of fixed column numbers as in the code below from putex4.gms.

 scalar lineonpage /15/;

 Put 'Hello' #(lineonpage+3) 'Goodbye';

 

The line number is related to the current page.
When obeying a # GAMS does not reset the column in which printing occurs as illustrated by output above.  One would need to add @1 if also desiring to start in column 1.