Spawn

(Engine-Level Function)

Description: Runs another Windows™ program.
Returns: Nothing
Usage: Script Only.
Function Groups: Software and Hardware
Related to: DLL
Format: Spawn(Command)
Parameters:  
Command

Required. The text string that will launch a program. If the name of a file is provided, the program associated with the given file extension will be launched. Similarly, if a URL is provided, a web browser will be launched.

Command should also contain any parameters necessary for the execution of the program. These parameters must be delimited from the command and other parameters by one or more space characters. If the command contains spaces, the command must be surrounded in double quote characters. (see examples).

If you wish to include environment variables in your command, you must spawn the command processor, CMD to run that command.

Comments:

Using the Spawn statement does not stop the execution of VTScada.

Within an Anywhere Client session, this function can be used to open a web link but not launch a program.

Examples:

Spawn("C:\Test Code\RunMe.BAT 1 2");

will be interpreted as the command C:\Test with the parameters Code\RunMe.BAT, 1 and 2.

Spawn("""C:\Test Code\RunMe.BAT"" 1 2");

will be interpreted as the command "C:\Test Code\RunMe.BAT" with the parameters 1 and 2.

Spawn("cmd /c ""dir 2>&1 >%TEMP%\Dirlist.txt"" ");

will redirect the directory contents of the current folder to a file named Dirlist.txt in the Windows temp folder, with errors (2) redirected to stdout (&1).

  GUITransform(243, 273, 326, 252,
               1, 1, 1, 1, 1 { Scaling              },
               0, 0          { Movement             },
               1, 0          { Visibility, Reserved },
               0, 0, 0       { Selectability        },
               Scope(Code, "DrawingTools", TRUE)\ProgramSpawn(
                                              "https://www.vtscada.com", 
                                              "Trihedral"));

This will add a button to a page, labeled "Trihedral", which will open the Trihedral website using the default browser when clicked.