Bill Allombert on Thu, 15 Dec 2005 14:28:30 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: reading environment variables into gp?


On Thu, Dec 15, 2005 at 12:40:00PM +0000, Prof. J. E. Cremona wrote:
> It would be very helpful if a gp script could read the value of a (unix)
> environment variable, into a string or integer variable.
> 
> For example, something like
> 
> s=getenv("MY_ENV_VAR");
> 
> would result in s being a string variable.  The C function getenv() does
> this, so perhaps it would be simply a question of install-ing it?

You can do
s=Strexpand("$MY_ENV_VAR").

You cannot install getenv() because it return a char * and there are no
prototype code for this type. 

On  the other hand I don't know how to set an environment variable inside
GP, so I use
install("setenv","vssD1,L,")
setenv("MY_ENV_VAR","MY_VALUE");

Cheers,
Bill.