home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / SETPATH.ZIP / SETPATH.DOC < prev    next >
Encoding:
Text File  |  1991-02-01  |  4.2 KB  |  105 lines

  1.                               ==============
  2.                                SET PATH 1.0
  3.                               ==============
  4.  
  5.                                 Programmer
  6.                              Scott Burkhalter
  7.                           723 S. Main St. Apt #1
  8.                               Ann Arbor, MI
  9.                                 48104-2953
  10.  
  11.  
  12. DISCLAIMER
  13. ==========
  14.  
  15. This program is hearby released into the Public Domain, for use by
  16. whomever deems it useful.  There is no Implied Warrenty or Customer
  17. Support.  If it doesn't work on your 'puter, delete it.
  18.  
  19.  
  20. DISTRIBUTION
  21. ============
  22.  
  23. If you distribute this program, please include all the files.  It's pretty
  24. useless without the SETPATH.BAT file, for instance.  There's some bug in
  25. Quick Pascal 1.0 which won't allow you to set environment variables from
  26. within an executable, so the batch file must do the actual path setting.
  27. I don't believe that this is too much of a hassle, as the required batch
  28. file is quite small.
  29.  
  30. If you don't like typing in a 7 letter filename, feel free to rename the
  31. batch file anything you want.
  32.  
  33.  
  34. EXECUTION
  35. =========
  36.  
  37. First, copy the SETPATH.BAT & SETPTH10.EXE programs a directory found in
  38. your path. ( usually C:\DOS or C:\UTILS or C:\BIN )
  39.  
  40. To use SETPATH, type SETPATH (or whatever you renamed it to) at the DOS
  41. prompt, and hit return.  The editing keys that are available when the
  42. program is running are displayed on the bottom of the screen.  Pressing
  43. RETURN exits the edit mode, and SETPATH will ask you if you want to keep
  44. the changes that you made.  If you do want to keep the changes, press
  45. the 'Y' key.  If you don't want to keep the changes, press 'N' key.
  46.  
  47. Type path at your DOS prompt to see if the changes actually occured at the
  48. DOS level.
  49.  
  50.  
  51. TECH NOTES
  52. ==========
  53.  
  54. If anybody out there understands why Quick Pascal won't let you change
  55. environment variables from within a program, write me.  I would like to
  56. discuss the issue with whoever wishes to correspond.
  57.  
  58. It seems to me that the PATH variable must be pushed onto a stack by the
  59. executable that is created by the Quick Pascal compiler.  It is then poped
  60. off the stack and "restored" on exit of the program.  Therefore, any
  61. changes made to the environment variable would be nullified by the
  62. restoration on exit.
  63.  
  64. Of course, this could all just be my imagination, and I just haven't
  65. discovered the proper way to do this in Pascal.  But, I'm pretty thorough,
  66. and I've tried many different approaches to the problem, with little
  67. success byeond the batch file solution.  The QP documentation says to use
  68. the /c switch with command.com, in order to execute a copy of command.com,
  69. passing it the command line parameters required for the desired command.
  70.  
  71. For example:
  72.  
  73.         SwapVectors;
  74.         Exec( 'COMMAND.COM','/c DIR *.EXE' );
  75.         SwapVectors;
  76.  
  77. The command "SwapVectors;" stores the interrupt vectors for safe keeping.
  78. This is in case the called program messes around with the interrupts.  The
  79. "Exec( 'COMMAND.COM','/c DIR *.EXE' );" command would execute a copy of
  80. COMMAND.COM, running the DOS command "DIR *.EXE".  This would obviously
  81. give you a list of the ".EXE" files in the present directory.  The second
  82. "SwapVectors;" command restores the interrupt vectors to their original
  83. values.
  84.  
  85. My theory is this:
  86.  
  87.         Whenever you run a copy of COMMAND.COM, you are in essence
  88.         using a DOS within a DOS.  Not exactly multitasking, but
  89.         the basic idea is this:  Any parameters you change, strictly
  90.         concerning DOS parameters, will remain changed only so long
  91.         as you are within the current command shell.
  92.  
  93.         As soon as you type "EXIT", the original states of the various
  94.         parameters are restored.
  95.  
  96.         Therefore, if I'm forced to call command.com from within a
  97.         program in order to execute an internal command, I will
  98.         inevitably lose the effects of that command when I exit
  99.         command.com and restore execution to my program.
  100.  
  101.         I'm sure you can see the problem.
  102.  
  103.         Again, if any of you people out there have a solution to this
  104.         little puzzle, feel free to write me.  I will appreciate it.
  105.