Dec 232017
Allows you to manipulate the enviroment with TP4.
File ENV.ZIP from The Programmer’s Corner in
Category Pascal Source Code
Allows you to manipulate the enviroment with TP4.
File Name File Size Zip Size Zip Type
DEMOENV.PAS 2561 987 deflated
ENV.PAS 5902 1892 deflated
READ.ME 3814 1383 deflated

Download File ENV.ZIP Here

Contents of the READ.ME file

Turbo Pascal Ver 4.0 Unit: ENV.PAS / Author: David Bennett / Date: 1-12-88

This Turbo Pascal unit will allow the user EASY access the the MS-DOS
environment variables.

This unit is release to the public domain
in the hopes that other writers will do the same...

Take a look at the demo program ENVDEMO.PAS so you will understand
more fully how easy these routines are to use.

- Files in this archive:

FileName Description
-------- -----------
DEMOENV.PAS Turbo Pascal Version 4.0 Demonstration of ENV.PAS unit.
ENV.PAS Environment Variable access unit.
READ.ME This File.

- Description of the ENV.PAS


EnvMax = 20; { Array Size for EnvArray }


EnvStr = String[255]; { String type used by ENV.PAS }

EnvArray = Array[1..EnvMax] of EnvStr; { Array type used by EnvParse }
{ and EnvAssign }

EnvRecord = Record { Record type that hold env data }
Pos : Byte; { Seq position of the var in environment }
Name, { Name of the variable }
Data : EnvStr; { Data the variable contains }


* Declaration : Function EndEnv;

Function : Returns true if at end of environment area.

Result Type : Boolean.

Remarks : It is a good idea to check this after calls to either
FirstEnv or NextEnv.

* Declaration : Procedure FirstEnv(Var EnvBuf : EnvRecord);

Function : Returns the first environment variable in a variable assigned
to the record type EnvRecord.

Remarks : This procedure is good to call before entering a loop.

* Declaration : Procedure NextEnv(Var EnvBuf : EnvRecord);

Function : Returns the next environment varaible in order after the last
call to NextEnv or FirstEnv.

Remarks : If there are is no next environment variable this procedure
returns a blank record. I.E. EnvBuf.Pos = 0. And EndEnv
will return TRUE.

* Declaration : Procedure GetEnvStr(Var EnvBuf : EnvRecord);

Function : Returns the position and data of an environment variable.

Remarks : Before calling the procedure you must first load the record
field NAME with the variable you want the data for. I.E.

EnvBuf.Name := 'PATH';

Will return the position in EnvBuf.Pos and the data in

* Declaration : Procedure EnvParse(EnvData : EnvStr; Var EnvList : EnvArray);

Function : The procedure will parse and environment string containing
multiple directories seperated by semi-colons ';' into
seperate directories contained in an array of type EnvArray.

Remarks : You must first locate the environment data you wish to
parse into seperate strings before using the procedure. I.E.

EnvBuf.Name := 'PATH';

Will parse the seperate directories of the PATH variable into
the array EnvList (EnvList can be any array of type EnvArray)

* Declaration : Procedure EnvAssign(Var F : Text; EnvVar, FileName : EnvStr);

Function : Will assign a variable of type Text to a DOS file using the
specified environment string.

Remarks : EnvAssign will first look for an existing file (FileName)
in the current directory. If it is'nt there it will look
thru every directory in the environment variable (EnvVar)
for the file. If no file (FileName) is found then EnvAssign
will assign (F) to a non-existent file (FileName) in the
directory that can be ReWritten.

 December 23, 2017  Add comments

Leave a Reply