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