INVOKE |
Execute Operating System Command |
To invoke command:
INVOKE [CONTROL] [HIDE] [WAIT] command$[,ERR=stmtref]
command$ |
String expression to be passed to the operating system command processor for execution. |
task$ |
Windows task. String expression. |
stmtref |
Program line number or statement label to which to transfer control. |
CONTROL |
(Windows Only) Keyword that, if supplied, will request that the command "Run as administrator". |
HIDE |
(Windows Only) Keyword that, if supplied, will request that the command be run in hidden/minimized window. |
WAIT |
(Windows Only) Keyword that, if supplied, will request that system wait for the command to complete before returning. |
The INVOKE directive enables a statement in a program to be processed by the operating system as if it were entered as a command from the terminal. It provides access to most operating system utilities and facilities from within a PxPlus program.
In Execution mode, character strings are passed from a program to the operating system.
In Command mode, entering a line of code that starts with a quotation mark (i.e. "statement"[, ERR=stmtref]) is the same as using the word INVOKE to start the directive.
In Windows, to accommodate the way Windows searches for programs and determines the type of program to run, it is best to identify the type of file in the Command line (e.g. "XCOPY.EXE" or "MYJOB.BAT").
If you are not concerned about the return status of a command and are running PVX UNIX and PVX Windows, there is no difference between using an INVOKE directive and the SYS( ) function. When SYS( ) is used under Windows, PxPlus waits for the spawned task to complete or for the program to be reactivated via the mouse. When the INVOKE directive is used under Windows, PxPlus spawns the task and continues without waiting for the task to complete.
Use the INVOKE WAIT directive to wait for the task, which is the same as using the SYS( ) function. If the 'IW' system parameter is disabled (Off), the user can force PxPlus to exit the wait state and continue to run by clicking on the PxPlus window or changing focus to it.
Use INVOKE HIDE to spawn a task in a minimized window.
INVOKE command$[,ERR=stmtref]
Use the INVOKE directive to have the operating system treat a character string from a program as an operating system command from the terminal.
Example:
invoke env("COMSPEC")+" /K DIR C:\WINDOWS"
Use INVOKE to start a background process in PxPlus. Under UNIX, output generated by the operating system command may result in strange display behavior. In particular, PxPlus will not know where the cursor is nor be able to restore the screen if a window is pushed/popped. This is because the output from the operating system command is not intercepted by PxPlus and is therefore unknown to it.
When you INVOKE another copy of PxPlus under UNIX, it is recommended that you also redirect stdin, stdout, and stderr to null files.
Example:
invoke arg(0)+"program >/dev/null >2/dev/null </dev/null"
SYS( ) Invoke Operating System Command
'IW' Force INVOKE WAIT