Directives
INVOKE Execute Operating System Command
   
Formats 1. Invoke: INVOKE command$[,ERR=stmtref]

2. Minimize (In Windows): INVOKE HIDE task$[,ERR=stmtref]

3. Wait (In Windows): INVOKE WAIT task$[,ERR=stmtref]

Where:

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.


*Note* In Command mode, ProvideX interprets a statement as an INVOKE directive if it begins with an double quotation mark ( " ).


   
Description 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 ProvideX 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").

Under WindX, use INVOKE "[WDX]...". See [WDX] Direct Action to Client Machine.

Tip: Use the SYS( ) function instead of the INVOKE directive if you wish to test the successful conclusion of an operating system command.

If you are not concerned about the return status of a command and are running PVX UNIX and PVX Windows/DOS, there is no difference between using an INVOKE directive and the SYS( ) function. When SYS( ) is used under Windows, ProvideX 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, ProvideX spawns the task and continues without waiting for the task to complete. Use INVOKE WAIT directive to wait for the task, which is the same as using the SYS( ) function. Use INVOKE HIDE to spawn a task in a minimized window.

   
See Also SYS( ) Function.
   
Format 1 Invoke

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; e.g.,

0010 INVOKE ENV("COMSPEC")+" /K DIR C:\WINDOWS"

The ENV("COMSPEC") when running on Windows determines the correct command processor to be used. Some Windows commands (such as COPY and DIR) are built-into command process and can be CALLed using this type of statement.

Background Tasks in ProvideX

Use INVOKE to start a background process in ProvideX. Under UNIX, output generated by the OS command may result in strange display behaviour. In particular, ProvideX 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 OS command is not intercepted by ProvideX and is therefore unknown to it. When you INVOKE another copy of ProvideX under UNIX, we recommend that you also redirect stdin, stdout, and stderrto null files; e.g.,

INVOKE ARG(0)+"program >/dev/null >2/dev/null </dev/null"



*Note* ARG(0)returns the name of the 'pvx' executive as entered in the original command line. Please make sure that this is an absolute pathname or that ProvideX can be found in the system path search rules.


   
Format 2 Minimize (In Windows)

INVOKE HIDE task$[,ERR=stmtref]

In Windows, the INVOKE HIDE format minimizes the invoked task when it starts.

   
Format 3 Wait (In Windows)

INVOKE WAIT task$[,ERR=stmtref]

In Windows, the INVOKE WAIT format causes the ProvideX session to wait until the application terminates or the user reactivates the task.