home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / ibm1 / do101j2.arj / DOIT.SCR < prev    next >
Encoding:
Text File  |  1992-01-03  |  2.9 KB  |  78 lines

  1. .pg wi full clr
  2. /GOSUB DOHEADER
  3.     Executes DOS commands and programs.
  4.  
  5.     »cy«{flags}»#«             Optional flags that control the display
  6.                         during command execution:
  7.                         »ye«P»gy« = »wh«pause after execution»#«
  8.                         »ye«A»gy« = »wh«Abort Script on Error
  9.                         »ye«C»gy« = »wh«Force command interpreter to be used
  10.  
  11.     »cy«{command}»#«           The actual DOS command to be executed.
  12.                         »%t«DO»#« executes another shell to
  13.                         execute the command. Variables in
  14.                         »cy«{command}»#« will be expanded to their
  15.                         values before execution.
  16.  
  17. .pg clr
  18.     »%t«DoIt»#« will swap as much of the »%t«DO»#« program out of memory as it
  19.     can before executing the command.  If you have »ye«EMS»#«, it will
  20.     do that, otherwise, it will create a »gr«swap file»#« on the current
  21.     directory.
  22.  
  23.     »%t«DoIt»#« will search the DOS path for the file to be executed.
  24.     If it can't find the file, it will pass the command line to
  25.     the shell defined by the environment variable "»ye«COMSPEC»#«".
  26.  
  27.     If no extension is entered, »%t«DoIt»#« (and DOS) searches for files
  28.     with extensions "»ye«COM»#«", "»ye«EXE»#«", and "»ye«BAT»#«" in this order in each
  29.     of the directories of the path.
  30.  
  31. .pg clr
  32.     »%t«DoIt»#« stores the return code from the executed program in the
  33.     variable "»ma«ERRORLEVEL»#«".  »bl«NOTE»gy«:»#« is a secondary command
  34.     processor is run, ERRORLEVEL will probably »re«NOT»#« reflect the
  35.     correct outcome.  This would be a problem if you run BATch
  36.     files from »%t«DO»#«.  BATch files required a secondary command
  37.     processor to run. If you need to capture the ERRORLEVEL
  38.     correctly, convert your BATch files to »%t«DO»#« scripts.
  39.  
  40. .pg clr
  41.     We'll use the »cy«DOS "DIR/w"»#« command to illustrate the operation
  42.     of the »%t«DoIt»#« command.  Press »bo«<enter>»#« to execute each of
  43.     the commands after you have examined them.
  44. .pg clr
  45.     First a simple directory:
  46. .go 1 10
  47. |!DIR/w
  48. /GOSUB DOHEADER
  49.     That went by too fast to get a good look at. Let's use the
  50.     "»cy«P»#«" flag to pause the display before returning to the »%t«DO»#«
  51.     script.  Press »bo«<enter>»#« after viewing the directory.
  52. .go 1 10
  53. |!P;DIR/w
  54. /GOSUB DoHeader
  55.     »wh«That's better»+re«!»#«
  56.  
  57.     To demonstrate the way »%t«DoIt»#« returns the »ye«ERRORLEVEL»#«, we'll
  58.     excute another version of »%t«DO»#« to run the script »ye«ERRTEST.SCR»#«.
  59.     Press »bo«<enter>»#« to execute the command.
  60.  
  61. |!DO ERRTEST
  62.  
  63.     Now let's look at the error level (press »bo«<enter>»#« to display
  64.     line):
  65.  
  66. |   »cy«ERRORLEVEL returned»gy«:  »re«%ERRORLEVEL»#«
  67.  
  68. /GOTO DOEND
  69. :DOHEADER
  70. .wi full clr
  71.     »cy«COMMAND NAME»gy«: »%t«DoIt»ye«
  72.  
  73.     ![{flags};]{command}
  74. /CW
  75. /RETURN
  76. :DOEND
  77. /ENDEXEC CLEAR
  78.