Previous mail
Next mail
Unformatted/full headers
Overview 10 days
Subject
Date
Thread
Author
From: Frank Heckenbach
Subject: Environment Variables within Code.
Date: 15 Nov 2002, 13:20:24
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
Previous mail
Next mail
Unformatted/full headers
Overview 10 days
Subject
Date
Thread
Author
| Author | Subject | Date |
|---|---|---|
| Marco van de Voort | Environment Variables within Code. | 14 Nov 2002, 17:59:05 |
| The Chief | Environment Variables within Code. | 14 Nov 2002, 21:02:01 |
Note: This page contains information that does not originate from the owner of this web site, but from the authors of the mails archived. The owner of this web site is not responsible for the content of such information. Any use of that infomation requires the consent of the respective author.
Where WWW addresses (URLs) in the mails archived are marked as hyperlinks, this is only for the comfort of the reader. The content of the web pages linked to like this does not necessarily reflect the opinion of the owner of this web site or of the authors of the mails archived. The owner of this web site is not responsible for the content of such web pages. Those pages are explicitly not to be considered as part of the content of this page, but merely as references.
This page was created by Crystal 0.999 (Linux 2.4.27/i686).