Shell.ExecuteMode

From Xojo Documentation

Property (As Shell.ExecuteModes )
aShell.ExecuteMode = newShell.ExecuteModesValue
or
Shell.ExecuteModesValue = aShell.ExecuteMode

Supported for all project types and targets.

Controls the mode in which the shell operates. The shell can be running in Synchronous, Asynchronous, or Interactive modes.

Notes

See Shell.ExecuteModes for descriptions of each available mode.

To access the DataAvailable event handler, you can subclass Shell or use AddHandler.

Sample Code

The following terminal application allows you to submit Unix commands using the interactive mode. The interface consists of two TextFields, InputField, in which the user can enter a command, and OutputField that displays the results.

The Open event for the window initializes the shell object (declared as a property of the window).

mShell = New Shell
mShell.ExecuteMode = Shell.ExecuteModes.Interactive

The user can type a unix command into the TextField, InputField. When they press Return, the following code in the TextField's KeyDown event runs. The Write method sends the command to the Shell's input buffer.

If Key = Chr(13) Then
If Not mShell.IsRunning Then
mShell.Execute "sh"
End If
mShell.Write(InputField.Value)
mShell.Write(Chr(13))
InputField.Value = ""
Return True
Else
Return False
End If

A Timer calls the ReadAll method in its Action event and displays the output in OutputField:

If mShell <> Nil Then
Var output As String = mShell.ReadAll
If output <> "" Then
OutputField.SelectedText = output
End If
End If