home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pathutil / desetp12.zip / SETPATH.DOC < prev    next >
Text File  |  1991-09-07  |  10KB  |  242 lines

  1.  
  2.  
  3.                                     SETPATH
  4.  
  5.        A Utility for showing or setting the DOS environment PATH string
  6.                         (Version 1.2 - September 8, 1991)
  7.         Copyright (c) Donald E. Ekman 1990, 1991.  All rights reserved.
  8.  
  9.  
  10.  
  11. SETPATH either prints or sets the current PATH environment variable.  When
  12. setting the PATH variable, SETPATH expects a PATH string in the form required
  13. by DOS, or the name of a file containing the wanted PATH string.  In either
  14. case, SETPATH places that string in the active environment, replacing any
  15. existing PATH string.  The new string need not be the same size as the current
  16. string, but if it is longer, there must be enough available environment space
  17. to accommodate it.  In particular, the string may be longer than the 128-byte
  18. limit imposed by the DOS command line buffer, but to use this feature, the PAT
  19. string must come from a file.                                                 
  20. SETPATH has been tested with DOS Versions 2.1 through 3.3, 4.01, and 5.0; it
  21. has not been tested with Version 4.0.  Because SETPATH uses undocumented
  22. features of DOS to find the active environment, its correct operation for
  23. versions of DOS with which it has not been tested is not assured.  (The author
  24. has received reports that SETPATH also works correctly with the 4DOS and NDOS
  25. replacements for COMMAND.COM, but he has not personally verified this.)
  26.  
  27. USAGE
  28.  
  29. SETPATH is invoked by:
  30.  
  31.      SETPATH
  32.  
  33.      SETPATH path_string
  34.  
  35.      SETPATH -f[d:\path]filename
  36.      SETPATH -F[d:\path]filename
  37.      SETPATH /f[d:\path]filename
  38.      SETPATH /F[d:\path]filename
  39.  
  40. where:
  41.  
  42.      path_string is the new PATH environment variable string in the same form
  43.                  required by the DOS PATH command.  (Do not include "PATH=".)
  44.  
  45.      filename    is the name of a file containing the new PATH string.  The
  46.                  drive path qualifiers are optional.  No space is permitted
  47.                  between the switch (-f, -F, /f, or /F) and its argument.  The
  48.                  file content must have the form:
  49.  
  50.                  PATH=any_wanted_text_string
  51.  
  52.                  The word PATH may be in any combination of upper and lower case
  53.                  letters.  This word and the following equals sign are required
  54.                  to help prevent using the wrong file, and must be the first
  55.                  five characters in the file except for spaces and control
  56.                  characters such as tabs and newlines.  (See NOTES below.)
  57.  
  58. If no argument is given, SETPATH locates and displays the current PATH
  59. environment variable.
  60.  
  61. MESSAGES
  62.  
  63. SETPATH first displays a copyright notice, followed by either the current path 
  64. environment variable string (if no argument is given), a successful completion
  65. message, or an error message.  In the event of any error, the original PATH
  66. string is left undisturbed.
  67.  
  68. Error Messages
  69.  
  70. An error message appears whenever SETPATH cannot perform its requested
  71. operation.  The following error messages are possible:
  72.  
  73.      Too many arguments    (1)   [Numbers in parentheses are values returned
  74.                                  by SETPATH; these may be tested in a batch
  75.                                  file using the "if errorlevel" test.]
  76.  
  77.           SETPATH was invoked with more than one argument.  This message will
  78.           also occur if one or more spaces are left between the file switch and
  79.           its argument.
  80.  
  81.      Can't open path file [d:\path]filename    (2)
  82.  
  83.           SETPATH was unable to open the specified file for read only.
  84.  
  85.      Failure seeking end of [d:\path]filename    (3)
  86.  
  87.           SETPATH was unable to position its pointer to the end of the file
  88.           using the C library function fseek.  Recreate the file.  If the
  89.           condition persists, notify the author.
  90.  
  91.      Failure in ftell with [d:\path]filename    (4)
  92.  
  93.           SETPATH was unable to determine the length of the file using the C
  94.           library function ftell.  Recreate the file.  If the condition
  95.           persists, notify the author.
  96.  
  97.      Failure allocating new PATH buffer    (5)
  98.  
  99.           Inadequate memory was available to allocate temporary buffer space for
  100.           the new path string.  This memory must exist within the 640K DOS lower
  101.           memory.  Release some TSRs if necessary.
  102.  
  103.      Path file must begin with PATH=    (6)
  104.  
  105.           The specified file was successfully opened, but it did not begin with
  106.           "PATH=".
  107.  
  108.      Not enough environment space for new path    (7)
  109.  
  110.           The new path is too long to fit in the available environment space.
  111.           See your DOS manual for information on how to increase the environment
  112.           space. If you are using a secondary command shell, see the section
  113.           headed NOTES below.
  114.  
  115. Normal Completion Message
  116.  
  117. When SETPATH has successfully placed the new PATH string into the environment,
  118. it issues the message:
  119.  
  120.      New PATH string successfully placed in environment.    (0)
  121.  
  122. If SETPATH is invoked with no argument, it displays the copyright notice,
  123. followed by the current path environment variable string, and returns a value
  124. of 0.
  125.  
  126. NOTES
  127.  
  128. The file must contain a copy of the new PATH string that is wanted in the
  129. environment, except that it may contain spaces and control characters such as
  130. tabs and newlines.  Before placing the file content in the environment, SETPATH
  131. changes any lower case letters in the word "path" to upper case and squeezes
  132. out all blanks and all control characters.  (SETPATH defines a control character
  133. as any character in the range 0x00-0x1f and the character 0x7f.)  If you do use
  134. newlines to separate the elements of your PATH string, do not forget the
  135. required semicolons; SETPATH will NOT add them automatically.
  136.  
  137. SETPATH searches for and modifies the active environment (given an argument).
  138. Normally this is the root environment, which was created when you booted.
  139. However, if you shell out of a program or run a secondary command processor, or
  140. if you explicitly run a shell of COMMAND.COM, then the active environment will
  141. be different from the root environment.  The distinction is important because it
  142. is the active environment, rather than the root, that gets passed (as a copy)
  143. to a program and is also used by DOS for the path and prompt.
  144.  
  145. When a program or a user creates a secondary shell, DOS does not insure that
  146. the environment used by the shell is at least as large as the one in the root.
  147. Instead, by default, it looks at how much of the environment is actually in use
  148. and rounds this up to a multiple of 16 bytes.  With DOS 3.2 and later, you can
  149. set a shell with the command
  150.  
  151.      command /e:xxx
  152.  
  153. and adjust the size of the environment.  Unfortunately, most application
  154. programs that shell out to the operating system do not use this feature, so the
  155. active environment in the shell has very little extra room.
  156.  
  157. If an inherited environment is too small, there is a way around the problem.
  158. Before loading the program from which you want to shell, issue several commands
  159. of the form:
  160.  
  161.      set a=junkjunkjunkjunkjunkjunk
  162.  
  163. Then, in the shell, use:
  164.  
  165.      set a=
  166.  
  167. The space created by the bytes taken up by the initial SET commands will be
  168. available after you remove the a variable.
  169.  
  170. BUGS AND INCOMPATIBILITIES
  171.  
  172. Yes, a section on bugs and incompatibilities.  All software should come with
  173. documentation that contains such a section, but, alas, few do.
  174.  
  175. Bugs
  176.  
  177. There are no presently known bugs in SETPATH.
  178.  
  179. Incompatibilities
  180.  
  181. The following compatibility problems have been reported.  Most appear to 
  182. result from certain software assuming that the path environment variable
  183. cannot be longer than 128 bytes.  There is no general solution to this
  184. problem that can be implemented in SETPATH.
  185.  
  186. DOS 4.01.
  187.  
  188. The DOS backup program appears to have a problem with long path statements.
  189. For example, if one enters "backup c: a:", the backup program dies with the
  190. message "No source drive specified."  This appears to be limited to DOS 4.x.
  191.  
  192. An unspecified version of zoo ends with the message "Abnormal program 
  193. termination."  Whether zoo correctly performs its intended task before this
  194. message appears was not reported.  Again, this is limited to DOS 4.x.
  195.  
  196. Mathematica 1.2, which uses the PharLap DOS extender, displays a curious
  197. error under DOS 4.01.  If an external program is run, and then run again,
  198. the second execution of that program terminates with an (unspecified) error
  199. message.
  200.  
  201. DOS 5.0
  202.  
  203. Although SETPATH works correctly with DOS 5.0, the DOS PATH command, when
  204. used with no argument, displays only the first 128 bytes of the path
  205. environment variable.  This misfeature is new with DOS 5.0.  Instead of the
  206. DOS PATH command, use SETPATH without an argument.  SETPATH will display the
  207. entire path variable.
  208.  
  209. DOS Version Independent
  210.  
  211. Turbo C++ does not operate properly when the portion of the path variable
  212. specifying the Turbo C++ directory appears after byte 128 in the path
  213. variable.  This was cured by placing the reference to that directory within
  214. the first 128 bytes of the path variable.
  215.  
  216. PROGRAMMING
  217.  
  218. SETPATH was written in C, and compiled with the Microsoft C Version 5.10
  219. compiler, and linked with the Microsoft Version 5.03 linker.  The small memory
  220. model was used, which required special treatment of the environment space, which
  221. is accessible only with far pointers.
  222.  
  223. LICENSE
  224.  
  225. You may use this program and distribute it freely, provided that not charge
  226. is made for its distribution, and all copyright notices are retained.  SETPATH
  227. is a copyrighted program.  All ownership rights remain with the author.  You
  228. may not use this program, or any portion of it, in any derivative work without
  229. the express permission of the author.
  230.  
  231. If you distribute this program, please keep this documentation file with it in
  232. some archived form.  If you have any comments or suggestions for improvement,
  233. send them to:
  234.  
  235.           Donald E. Ekman
  236.           3586 Berry Way
  237.           Santa Clara, CA  95051-1902
  238.  
  239.           Internet:  ekman@wdl30.wdl.loral.com
  240.                      ekman@ssd168.ssd.loral.com
  241.  
  242.