home *** CD-ROM | disk | FTP | other *** search
/ Phoenix CD 2.0 / Phoenix_CD.cdr / 24b / getenvr.zip / GETENVR.DOC < prev   
Text File  |  1986-01-19  |  4KB  |  100 lines

  1. GETENVR.DOC
  2.  
  3. INTRODUCTION
  4.  
  5. Starting with DOS 2.0, a series of strings known as the command
  6. processor's environment is available for use by  all DOS commands and
  7. programs.  DOS did not provided a mechanism for programs to directly
  8. access the command processor's environment.   Programs can only access a
  9. copy of this environment.  The assembly language program, GETENVR, shows
  10. how to access the command processor's environment.
  11.  
  12. BACKGROUND
  13.  
  14. The DOS manual under the SET command suggests entering keywords and
  15. parameters, while not meaningful to DOS, could be found and interpreted by
  16. programs.  This is a great idea but DOS only allows access through the
  17. "SET" command while in the command mode.  This means that an individual
  18. must enter these keywords and parameters manually.
  19.  
  20. PASSED ENVIRONMENT
  21.  
  22. When DOS loads a program, it also makes a copy of its environment and
  23. leaves the segment address to this copy at offset 2C hex (H) in the
  24. Program Segment Prefix (PSP).  If a program changes, modifies or adds to
  25. this copy of the environment, all is lost when the program terminates.
  26. None of this information is passed back to DOS.
  27.  
  28. ACCESSING COMMAND PROCESSOR'S ENVIRONMENT
  29.  
  30. The procedure GET_ENV is the heart of the program, GETENVR.  It determines
  31. the segment address of the active command processor's environment.  Once
  32. this address is known, any program can easily access this master
  33. environment.  The program GETENVR illustrates this by displaying all the
  34. strings in the master environment on the screen along with its address.
  35.  
  36. USING COMMAND PROCESSOR'S ENVIRONMENT
  37.  
  38. Now knowing the location of the master environment, new keywords and
  39. parameters can be added.  When being added, each string must be terminated
  40. with a null byte (0H), and the last string in the environment must be
  41. terminated by two null bytes.
  42.  
  43. The major limitation in using the environment is its limited space.  The
  44. original size is only 127 bytes.  The only way to expand this with DOS 2.X
  45. is to use the SET command to introduce a very long string which the
  46. application program can delete later.  This will only work if memory
  47. resident programs, like Bourland's SideKick (c), has been loaded.  With
  48. DOS 3.10, there is a round about way to increase the environment using a
  49. combination of documented and undocumented features of the shell command
  50. in the config.sys file.  The format is:
  51.  
  52.     SHELL=C:\COMMAND.COM C:\COMMAND.COM /P /E:##
  53.     
  54. Replace ## with the number of paragraphs (16 bytes) desired for the
  55. environment length.  The break down of this is:
  56.     - The first "C:\COMMAND.COM" is the location from where the
  57.       command processor will be initially loaded.
  58.     - The second "C:\COMMAND.COM" is the location from where the
  59.       transient portion of the command processor will be loaded.
  60.       - "/P" makes the second "C:\COMMAND.COM" the permanent command
  61.       processor.
  62.     - "/E:##" sets the environment size in paragraphs.
  63.  
  64. This method of expanding the master environment in DOS 3.1 has not been
  65. tested by the author.
  66.       
  67. MEMORY RESIDENT PROGRAMS
  68.  
  69. Memory resident programs can also use this capability.  The copy of the
  70. environment that is passed to these programs is not updated when changes
  71. occur in the command processor's environment.  Thus with the GET_ENV
  72. procedure, memory resident programs could then  access the master
  73. environment and be able to adept to a changing environment.
  74.  
  75. PROGRAM DETAILS
  76.  
  77. The algorthm used for determining the segment address of the command
  78. processor's environment is explained in detail in the .ASM file
  79. documentation. 
  80.  
  81. USER RESPONSIBILITIES
  82.  
  83. Since this program is released into the public domain, no restrictions are
  84. placed upon its use except that GETENVR.DOC, GETENVR.ASM and GETENVR.COM
  85. must be distributed free of cost and only the cost of the media can be
  86. charged. 
  87.  
  88. The author encourages comments.  Please leave comments, suggestions, or
  89. ideas in a message on Andy Smith's RBBS (301)-956-3396.
  90.  
  91. DISCLAIMER OF WARRANTIES AND LIMITATION OF LIABILITIES
  92.  
  93. The author has taken due care in writing this program, and the program is
  94. supplied as is.  The author makes no expressed or inmplied warranty of any
  95. kind with regard to this program.  In no event shall the author be liable
  96. for incidental or conseqential damages in connection with or arising out
  97. of the use of this program.
  98.  
  99. 19 Jan 85                Raymond Moon
  100.