home *** CD-ROM | disk | FTP | other *** search
- .pg wi full clr
- /GOSUB DOHEADER
- Executes DOS commands and programs.
-
- »cy«{flags}»#« Optional flags that control the display
- during command execution:
- »ye«P»gy« = »wh«pause after execution»#«
- »ye«A»gy« = »wh«Abort Script on Error
- »ye«C»gy« = »wh«Force command interpreter to be used
-
- »cy«{command}»#« The actual DOS command to be executed.
- »%t«DO»#« executes another shell to
- execute the command. Variables in
- »cy«{command}»#« will be expanded to their
- values before execution.
-
- .pg clr
- »%t«DoIt»#« will swap as much of the »%t«DO»#« program out of memory as it
- can before executing the command. If you have »ye«EMS»#«, it will
- do that, otherwise, it will create a »gr«swap file»#« on the current
- directory.
-
- »%t«DoIt»#« will search the DOS path for the file to be executed.
- If it can't find the file, it will pass the command line to
- the shell defined by the environment variable "»ye«COMSPEC»#«".
-
- If no extension is entered, »%t«DoIt»#« (and DOS) searches for files
- with extensions "»ye«COM»#«", "»ye«EXE»#«", and "»ye«BAT»#«" in this order in each
- of the directories of the path.
-
- .pg clr
- »%t«DoIt»#« stores the return code from the executed program in the
- variable "»ma«ERRORLEVEL»#«". »bl«NOTE»gy«:»#« is a secondary command
- processor is run, ERRORLEVEL will probably »re«NOT»#« reflect the
- correct outcome. This would be a problem if you run BATch
- files from »%t«DO»#«. BATch files required a secondary command
- processor to run. If you need to capture the ERRORLEVEL
- correctly, convert your BATch files to »%t«DO»#« scripts.
-
- .pg clr
- We'll use the »cy«DOS "DIR/w"»#« command to illustrate the operation
- of the »%t«DoIt»#« command. Press »bo«<enter>»#« to execute each of
- the commands after you have examined them.
- .pg clr
- First a simple directory:
- .go 1 10
- |!DIR/w
- /GOSUB DOHEADER
- That went by too fast to get a good look at. Let's use the
- "»cy«P»#«" flag to pause the display before returning to the »%t«DO»#«
- script. Press »bo«<enter>»#« after viewing the directory.
- .go 1 10
- |!P;DIR/w
- /GOSUB DoHeader
- »wh«That's better»+re«!»#«
-
- To demonstrate the way »%t«DoIt»#« returns the »ye«ERRORLEVEL»#«, we'll
- excute another version of »%t«DO»#« to run the script »ye«ERRTEST.SCR»#«.
- Press »bo«<enter>»#« to execute the command.
-
- |!DO ERRTEST
-
- Now let's look at the error level (press »bo«<enter>»#« to display
- line):
-
- | »cy«ERRORLEVEL returned»gy«: »re«%ERRORLEVEL»#«
-
- /GOTO DOEND
- :DOHEADER
- .wi full clr
- »cy«COMMAND NAME»gy«: »%t«DoIt»ye«
-
- ![{flags};]{command}
- /CW
- /RETURN
- :DOEND
- /ENDEXEC CLEAR
-