OS.EXECUTE

Top  Previous  Next

 

The OS.EXECUTE statement executes an operating system command. This function is not available on the PDA version of QM.

 

 

Format

 

OS.EXECUTE expr {CAPTURING var}

 

where

 

exprevaluates to the command to be executed (maximum 4096 characters).

 

varis a variable to receive captured output.

 

 

The OS.EXECUTE statement allows a QMBasic program to execute an operating system command. The program does not continue execution until the command terminates. QM attempts to redirect any output from the command back to the user's terminal but this is not always possible. Some commands may cause output to appear on the server system.

 

The CAPTURING clause captures output that would otherwise have gone to the terminal or phantom log file, saving it in the named variable with field marks in place of newlines.

 

The OS.EXECUTE statement returns two error codes. The  STATUS() function returns a non-zero value if QM detected an error and was unable to execute the command. For a zero STATUS() value, the OS.ERROR() function returns the termination status of the executed command. The interpretation of this value will depend on the command being executed.

 

 

Example

 

OS.EXECUTE "MKDIR TEMPDIR"

 

This statement uses the operating system MKDIR command to create a directory named TEMPDIR.