home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / environ / env.doc < prev    next >
Encoding:
Text File  |  1988-01-12  |  3.7 KB  |  114 lines

  1. Turbo Pascal Ver 4.0 Unit: ENV.PAS / Author: David Bennett / Date: 1-12-88
  2.  
  3. This Turbo Pascal unit will allow the user EASY access the the MS-DOS
  4. environment variables.
  5.  
  6. This unit is release to the public domain
  7. in the hopes that other writers will do the same...
  8.  
  9. Take a look at the demo program ENVDEMO.PAS so you will understand
  10. more fully how easy these routines are to use.
  11.  
  12. - Files in this archive:
  13.  
  14.   FileName     Description
  15.   --------     -----------
  16.   DEMOENV.PAS  Turbo Pascal Version 4.0 Demonstration of ENV.PAS unit.
  17.   ENV.PAS      Environment Variable access unit.
  18.   READ.ME      This File.
  19.  
  20. - Description of the ENV.PAS
  21.  
  22. CONSTANTS
  23.  
  24.     EnvMax    = 20;                  { Array Size for EnvArray     }
  25.  
  26. TYPES
  27.  
  28.     EnvStr    = String[255];                { String type used by ENV.PAS }
  29.  
  30.     EnvArray  = Array[1..EnvMax] of EnvStr; { Array type used by EnvParse }
  31.                                             {               and EnvAssign }
  32.  
  33.     EnvRecord = Record            { Record type that hold env data           }
  34.           Pos  : Byte;    {   Seq position of the var in environment }
  35.           Name,           {   Name of the variable                   }
  36.           Data : EnvStr;  {   Data the variable contains             }
  37.         End;
  38.  
  39.  
  40. PROCEDURES AND FUNCTIONS
  41.  
  42.   * Declaration : Function EndEnv;
  43.  
  44.     Function    : Returns true if at end of environment area.
  45.  
  46.     Result Type : Boolean.
  47.  
  48.     Remarks     : It is a good idea to check this after calls to either
  49.           FirstEnv or NextEnv.
  50.  
  51.  
  52.   * Declaration : Procedure FirstEnv(Var EnvBuf : EnvRecord);
  53.  
  54.     Function    : Returns the first environment variable in a variable assigned
  55.           to the record type EnvRecord.
  56.  
  57.     Remarks     : This procedure is good to call before entering a loop.
  58.  
  59.  
  60.  
  61.   * Declaration : Procedure NextEnv(Var EnvBuf : EnvRecord);
  62.  
  63.     Function    : Returns the next environment varaible in order after the last
  64.           call to NextEnv or FirstEnv.
  65.  
  66.     Remarks     : If there are is no next environment variable this procedure
  67.           returns a blank record. I.E. EnvBuf.Pos = 0. And EndEnv
  68.           will return TRUE.
  69.  
  70.  
  71.   * Declaration : Procedure GetEnvStr(Var EnvBuf : EnvRecord);
  72.  
  73.     Function    : Returns the position and data of an environment variable.
  74.  
  75.  
  76.     Remarks     : Before calling the procedure you must first load the record
  77.           field NAME with the variable you want the data for. I.E.
  78.  
  79.             EnvBuf.Name := 'PATH';
  80.             GetEnvStr(EnvBuf);
  81.  
  82.           Will return the position in EnvBuf.Pos and the data in
  83.           EnvBuf.Data.
  84.  
  85.  
  86.   * Declaration : Procedure EnvParse(EnvData : EnvStr; Var EnvList : EnvArray);
  87.  
  88.     Function    : The procedure will parse and environment string containing
  89.           multiple directories seperated by semi-colons ';' into
  90.           seperate directories contained in an array of type EnvArray.
  91.  
  92.     Remarks     : You must first locate the environment data you wish to
  93.           parse into seperate strings before using the procedure. I.E.
  94.  
  95.             EnvBuf.Name := 'PATH';
  96.             GetEnvStr(EnvBuf);
  97.             EnvParse(EnvBuf.Data,EnvList);
  98.  
  99.           Will parse the seperate directories of the PATH variable into
  100.           the array EnvList (EnvList can be any array of type EnvArray)
  101.  
  102.  
  103.   * Declaration : Procedure EnvAssign(Var F : Text; EnvVar, FileName : EnvStr);
  104.  
  105.     Function    : Will assign a variable of type Text to a DOS file using the
  106.           specified environment string.
  107.  
  108.     Remarks     : EnvAssign will first look for an existing file (FileName)
  109.           in the current directory. If it is'nt there it will look
  110.           thru every directory in the environment variable (EnvVar)
  111.           for the file. If no file (FileName) is found then EnvAssign
  112.           will assign (F) to a non-existent file (FileName) in the
  113.           directory that can be ReWritten.
  114.