home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / ENV12.ZIP / READ.ME < prev   
Encoding:
Text File  |  1988-02-03  |  4.2 KB  |  122 lines

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