Environment Variables within Code.
Hi, Is it possible to access environment variables within gpc code, for example $USER ? -- Thanks, Andrew McCall Internet/Linux System Administrator I.C.T. Division Oldham MBC Civic Centre West Street Oldham OL1 1UU Tel : 0161 911 3990 Fax : 0161 911 3998 Email : it.andrew.mccall@oldham.gov.uk ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.oldham.gov.uk **********************************************************************
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 -- Maurice Lombardi Laboratoire de Spectrometrie Physique, Universite Joseph Fourier de Grenoble, BP87 38402 Saint Martin d'Heres Cedex FRANCE Tel: 33 (0)4 76 51 47 51 Fax: 33 (0)4 76 63 54 95 mailto:Maurice.Lombardi@ujf-grenoble.fr
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 -- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html GPC download signing key: 51FF C1F0 1A77 C6C2 4482 4DDC 117A 9773 7F88 1707
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/
participants (5)
-
Andrew McCall -
Frank Heckenbach -
marcov@stack.nl -
Maurice Lombardi -
Prof A Olowofoyeku (The African Chief)