[fpc-devel] enumerating environment variables

Michael.VanCanneyt at Wisa.be Michael.VanCanneyt at Wisa.be
Sat Dec 11 17:05:22 CET 2004



On Sat, 11 Dec 2004, Vincent Snijders wrote:

> Michael.VanCanneyt at Wisa.be wrote:
> > 
> > On Fri, 10 Dec 2004, Vincent Snijders wrote:
> > 
> > 
> >>If true, how can I enumerate the environment variables like I do with 
> >>the dos unit using EnvCount and EnvStr from the dos unit.
> > 
> > 
> > You currently can not. Most platforms have the envp() pointer available, but
> > this is of course not very user friendly. I have added the
> > 
> > Function EnvironmentVariableCount() : Integer;
> > Function GetEnvironmentString(Index : Integer) : String;
> > 
> > functions to sysutils. (still needs committing, should be there shortly)
> 
> Thanks. No need to hurry though. I won't be using them before 1.9.6. ;-)

No, but I prefer to have them ASAP, they can be tested much longer in that
case, on all platforms.

I made a small typo, it's

Function GetEnvironmentVariableCount() : Integer;

The following should compile and run:

program testep;

uses sysutils;

Var
  I : Integer;

begin
  For I:=1 to GetEnvironmentVariableCount do
    Writeln(i:3,' : ',GetEnvironmentString(i));
end.


Michael.




More information about the fpc-devel mailing list