Augmenting environment variables

Top  Previous  Next

Environment variables may have items added to their beginning or their end as follows.

To add to the beginning

 

$setenv varname %sysenv.varname% value

 

To add to the beginning

 

$setenv varname value %sysenv.varname%

 

where

 varname is a user chosen environment variable name

 value contains text or a number

 %sysenv.varname% is the old text that was in the environment variable.

 

Note of caution using $SETENV Under windows 2000, XP and vista, environment variables are defined locally. After the GAMS model finished execution, the setting of the environment variable is lost. $SETENV can therefore not be used to pass information from a GAMS model to the outside world outside the confines of the GAMS model itself. Similarly only environment variables defined at core windows level are available. Even environment variables that were created by spawning an external program from GAMS are not available.

Example:

$onecho > cmd.cmd

set xxx=test

set xxx > cmd.set

$offecho

$call cmd.cmd

 

$echo xxx=%sysenv.xxx% > cmd.xxx

The result in cmd.set and cmd.xxx are not identical!!!!