home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
CPM
/
TURBOPAS
/
TP-UTIL.ARK
/
SRCHENV.SRC
< prev
next >
Wrap
Text File
|
1986-01-06
|
3KB
|
60 lines
{->>>>SearchEnvironment<<<<------------------------------------}
{ }
{ Filename: SRCHENV.SRC -- Last modified 10/20/85 }
{ }
{ This routine searches the DOS environment for a parameter, }
{ and if it finds the parameter, returns the value of that }
{ parameter as read from the environment. The function return }
{ value is set to True if the parameter is found. The value }
{ of the found parameter is placed in Value. If the parameter }
{ is not found, Value will be set to the null string. ('') }
{ The requested parameter is forced to upper-case before the }
{ search is begun, since COMMAND.COM capslocks the parameter }
{ when it is entered via the SET DOS command. }
{--------------------------------------------------------------}
FUNCTION SearchEnvironment(Parm : String80;
VAR Value : String80) : Boolean;
TYPE
String255 = String[255];
VAR
I,J,K : Integer;
EnvSegment : Integer;
EnvOffset : Integer;
TempString : String255;
BEGIN
SearchEnvironment := False; { Defaults to "not found" }
Value := ''; { Set Value to null string }
FOR I := 1 TO Length(Parm) DO { Caps lock the parm }
Parm[I] := UpCase(Parm[I]);
EnvSegment := MEMW[CSEG:$2C]; { Locate the DOS environment }
EnvOffset := 0; J := 0;
{ Until we run out of environment, search: }
WHILE MEM[EnvSegment : EnvOffset] <> 0 DO
BEGIN
TempString := '';
I := 1;
{ Here we copy an environment string into TempString: }
REPEAT
TempString[I] := CHR(MEM[EnvSegment : EnvOffset]);
I := SUCC(I);
EnvOffset := SUCC(EnvOffset)
UNTIL MEM[EnvSegment : EnvOffset]=0;
TempString[0] := CHR(EnvOffset-J); { Set length of TempString }
K := Pos('=',TempString); { Locate "=" in TempString }
IF K > 0 THEN { If there is an "=" in this string... }
IF Copy(TempString,1,K-1) = Parm THEN { If Parm is found }
BEGIN
SearchEnvironment := True; { We found it! }
{ Copy procedure's value into Value... }
Value := Copy(TempString,K+1,Length(TempString)-K);
Exit { ...and duck out of proc }
END;
J := EnvOffset+1;
EnvOffset := SUCC(EnvOffset)
END
END;
ßJi£æcE5╤ ∙╪z╪Ç┌çôÖZºµO≤├ö¿Éj▌