home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.update.uu.se
/
ftp.update.uu.se.2014.03.zip
/
ftp.update.uu.se
/
pub
/
rainbow
/
msdos
/
misc2
/
dialv23.lzh
/
FINDENV.INC
< prev
next >
Wrap
Text File
|
1985-08-03
|
2KB
|
63 lines
{********* This file is an "include" file to be used with DIAL.PAS. *********}
Function Find_Env ( ev : str255 ) : str255;
{
This procedure finds the variable the user wanted and returns as its result the
corresponding string. If it cannot be found, the null string is returned.
}
Const
env_size = 256;
Var
env_seg : Integer Absolute CSeg:$2C;
seg : Integer;
ofs : Integer;
ch : Byte;
no_more_env : Boolean;
one_null_seen : Boolean;
equals_seen : Boolean;
name : String[255];
value : String[255];
ii : Integer;
Begin
seg := env_seg; { Init segment address }
ofs := 0; { Offset 0 into that segment }
name := ''; { Variable name is initially null }
value := ''; { And its value also }
no_more_env := false; { Set true when we're done }
one_null_seen := false; { Set true when we see a null character }
equals_seen := false; { Set true when we see an "=" character }
find_env := ''; { Return at least this }
For ii := 1 to Length(ev) Do ev[ii] := UpCase(ev[ii]);
Repeat
Begin
ch := Mem[seg:ofs]; { Get the character }
no_more_env := one_null_seen and (ch = 0); { Set appropriate flags }
equals_seen := equals_seen or (ch = ord('='));
one_null_seen := (ch = 0);
If not no_more_env Then { If not done, check character }
If one_null_seen Then { End of a string, check results }
If name = ev Then
Begin
find_env := value; { Found it, return now }
no_more_env := true
End
Else
Begin
equals_seen := false; { Didn't find it. Re-init }
name := '';
value := ''
End
Else
If equals_seen Then { Store character in proper string }
Begin
If chr(ch) <> '=' Then value := value + UpCase(chr(ch))
End
Else
name := name + UpCase(chr(ch));
ofs := ofs + 1; { Increment offset pointer }
End;
Until no_more_env or (ofs > env_size);
End;