Hi,
Is it possible to access environment variables within gpc code, for example $USER ?
Andrew McCall a écrit:
Is it possible to access environment variables within gpc code, for example $USER ?
There is a GetEnv function in the module gpc.pas for that purpose. e.g.
username:=GetEnv('USER');
also
username:=CStringGetEnv('USER');
See gpc.pas in the units directory for the difference.
Maurice
Andrew McCall a ?crit:
Is it possible to access environment variables within gpc code, for example $USER ?
There is a GetEnv function in the module gpc.pas for that purpose. e.g.
username:=GetEnv('USER');
also
username:=CStringGetEnv('USER');
See gpc.pas in the units directory for the difference.
I think he wants to embed environment variables on the compiling machine in the code.
Marco van de Voort wrote:
Andrew McCall a ?crit:
Is it possible to access environment variables within gpc code, for example $USER ?
There is a GetEnv function in the module gpc.pas for that purpose. e.g.
username:=GetEnv('USER');
also
username:=CStringGetEnv('USER');
See gpc.pas in the units directory for the difference.
I think he wants to embed environment variables on the compiling machine in the code.
I don't know what makes you think so (generally I think a program would be more interested to know the user who's running it than who has compiled it), but if so:
gpc -DUSER="'$USER'" ...
will define USER as a macro (string constant), so something like
WriteLn (USER)
will work. (This is assuming USER is set, some systems use LOGNAME instead.)
Prof A Olowofoyeku (The African Chief) wrote:
Is it possible to access environment variables within gpc code, for example $USER ?
Check "getenv" in the DOS unit.
Also in the GPC unit (which is generally preferable to the Dos unit unless you're maintaining BP compatible code).
Frank
On 14 Nov 2002 at 15:55, Andrew McCall wrote:
Hi,
Is it possible to access environment variables within gpc code, for example $USER ?
Check "getenv" in the DOS unit.
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.bigfoot.com/~african_chief/