_SHELL System Variable

See Also

Specifies a program shell.

Syntax

_SHELL = cCommand

Remarks

The _SHELL system memory variable is used to prevent access to the Command window while a program is running in Visual FoxPro. The DO command with the name of a program to execute is usually stored to _SHELL.

You can also specify a command to execute when Visual FoxPro is started by placing the SHELL configuration item in your Visual FoxPro configuration file.

The following example demonstrates how _SHELL typically can be used.

  1. A startup program named Mystart.prg is used to launch another program named Myapp.prg. Mystart.prg stores the command to run Myapp.prg to _SHELL. This starts Myapp.prg. Before Visual FoxPro displays the Command window, _SHELL is checked for a command. If _SHELL contains a command, it is executed and Visual FoxPro then stores the empty string to _SHELL.

  2. After the initialization code in Myapp.prg is successfully executed, the command to launch Myapp.prg is stored again to _SHELL. Visual FoxPro does not execute the command or store the empty string to _SHELL, and access to the Command window is prevented. (The Command window cannot be accessed when _SHELL contains anything but the empty string).

  3. Before Myapp.prg finishes execution, it stores the empty string to _SHELL to restore access to the Command window.
    *** MYSTART.PRG ***
    ...
    _SHELL = "DO MYAPP.PRG"
    
    *** MYAPP.PRG ***
    *** Initialization Code ***
    ...
    *** Initialization Code successfully completed? ***
    _SHELL = "DO MYAPP.PRG" && Prevents access to Command window
    ...
    *** Clean up Code ***
    _SHELL = ""