Category : BASIC Source Code
Archive   : PB-EXEC.ZIP

Output of file : EXECTEST.BAS contained in archive : PB-EXEC.ZIP

'Exec% FUNCTION for PowerBASIC 2.10f
'CopyRight 1992 Dave Navarro, Jr - All Rights Reserved
'Licensed to Information Management Systems, Inc.

'Exec% - Function
' Usage: ErrorLevel%=Exec(Program$,CommandLine$)
' Where: Program$ is the full path and filename to execute
' if Program$ is null then COMSPEC (COMMAND.COM) is called
' CommandLine$ is the command line to pass to the program
' ErrorLevel% is the exit code set by the program that was
' called. If ErrorLevel% is negative, then there was an
' error in the Function.
'Error Codes: -1 Program$ not found
' -2 Unable to shrink memory to execute program
' -3 Unable to restore all memory after program was
' executed (partial restore was made)
' -4 Error during execution of program

'This is a replacement for PowerBASIC's SHELL"" command which always
'calls COMSPEC (COMMAND.COM) before executing the specified command
'line. In some cases, this means you can lose up to 128k just to
'reload COMMAND.COM. Exec% calls the program directly without
'going through COMSPEC first (unless Program$ is null)
'Another problem is that you can not always retrieve the exit code
'(error level) set by the program your calling, COMMAND.COM will
'interfere. Exec% was created as a function so that it will always
'return the exit code set by the program called.

'This is version 1.1 of a routine for PBTools:Lite 2.0, version 2 of
'this routine will allow swapping of your program to EMS or DISK before
'executing the shell, leaving only about 4k in memory.


PRINT "Free Memory Before EXEC:";Before&

PRINT "Free Memory Before EXEC:";Before&
PRINT "Free Memory After EXEC :";FRE(-1)
PRINT "Exit Code:";ExCode%