Q(uick)BASIC Function: SHELL

Quick View

SHELL

A function that returns an integer value that is the OS/2 process ID for the shelled process

Worth knowing

Useful and cross-version information about the programming environments of QBasic and QuickBasic.

Syntax
  • SHELL (commandstring$)
Description/Parameter(s)
commandstring$ The name of the OS/2 process to be executed, along with any command-line arguments that the executed process requires.
The SHELL function is used only in OS/2 protected mode.

Usage Notes

  • Like the SHELL statement, the OS/2 protected-mode SHELL function permits a BASIC program to execute another process. In addition, the SHELL function allows the BASIC program to continue execution without waiting for the child process to terminate, and returns the process ID of the child process.
  • This process ID is used by some of the OS/2 API functions (which can be called from BASIC).
Example

This example uses the SHELL function to execute three OS/2 commands.

CLS ON ERROR GOTO ErrHandler Ext$ = CHR$(34) + " EXE" + CHR$(34) 'The child process does: DIR | FIND " EXE" | SORT Child$ = "dir | find " + Ext$ + " | sort" ProcessID = SHELL(Child$) PRINT "Process ID is: ProcessID" END ErrHandler: SELECT CASE ERR CASE 73 PRINT : PRINT "You cannot use the SHELL function in DOS." CASE ELSE END SELECT END