[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
SWPRUNCMD() / SWPRUNCMDBAS() Execute child process.
------------------------------------------------------------------------------
Function : Execute a child process.
Syntax : lValue = SWPRUNCMD(cCommand, nuMem, cRunPath, cTempPath)
Return : TRUE if the command interpreter was executed.
FALSE if an error occurred
This function executes a child process of the current program, freeing
conventional memory occupied by the parent program. Any non conventional
memory used by the parent will remain allocated.
The parameters to SWPRUNCMD() are as follows:
cCommand: The name of the program, batch file or DOS internal command to be
executed, followed by any required parameters. An empty string will cause
the command interpreter to be loaded, giving a DOS prompt.
nuMem: The amount of memory in kilobytes (kb) to be freed prior to executing
the child process. If this parameter is passed as zero, as much memory as
possible will be freed.
cRunPath: The drive and directory to make current prior to executing the
child process.
cTempPath: The drive and directory where the swap function should create a
disk swap file containing the image (or partial image) of the parent
program. Note that XMS and EMS memory will be used in preference to a disk
swap file if available provided their use has not been prohibited through
the use of SWPUSEEMS() and SWPUSEXMS().
Note that this parameter may be overridden at runtime through the use of
the SWAP or BLINKER environment variables. For example:
SET SWAP=F:\TEMP;
or
SET BLINKER=/SDF:\TEMP
will cause the temporary diskfile to be created in F:\TEMP, regardless of
the value passed as a parameter to the SWPRUNCMD().
The swap function will always invoke the current command interpreter as
specified in the COMSPEC environment variable, which in turn will execute
cCommand. This allows the parent program to execute any internal or external
DOS command, a batch file or any program which can be executed from the DOS
prompt. The return code of the child process can be retrieved using the
function SWPERRLEV().
The return value is a logical (boolean) value indicating the success of the
SWPRUNCMD() call. Following an unsuccessful call to SWPRUNCMD(), the program
can use SWPERRMAJ() and SWPERRMIN() to determine the nature of the error.
Example:
success = SWPRUNCMD("",0,"","")
Shell to DOS, freeing as much memory as possible, save swap file to current
directory if required.
success = SWPRUNCMD("WIN",0,"C:\WINDOWS","F:\")
This command will execute Microsoft Windows, freeing as much memory as
possible. The swap function will change drive and directory to C:\WINDOWS
prior to executing the WIN command. If a temporary disk swap file is
required, it will be created on F:\
success = SWPRUNCMD("DIR /W",100,"","")
IF (!success)
? "Swap failed"
majerr = SWPERRMAJ()
minerr = SWPERRMIN()
? "Error codes :", majerr, minerr
ELSE
? "Swap succeeded"
? "Errorlevel :", SWPERRLEV()
ENDIF
Execute the DOS DIR command, first freeing 100KB, cretae the swap disk file
to the current directory if required. On return, check the swap function
return code. If the swap failed display the swap major and minor error
codes, if it succeeded, display the return code of the child process.
success = SWPRUNCMD("RRUN ABC",0,"","")
IF (!success)
? "Swap failed"
majerr = SWPERRMAJ()
minerr = SWPERRMIN()
? "Error code :", majerr, minerr
ELSE
? "Swap succeeded"
? "Errorlevel :",SWPERRLEV()
ENDIF
Execute the R & R report writer, checking for errors on return.
See Also:
SWPERRLEV()
SWPERRMAJ()
SWPERRMIN()
1220: Swap error
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson