The VisualApplets Scripting Console#
To open the Scripting Console in VisualApplets:
-
From menu Window, select Dock Windows and then Scripting Console.
The Scripting Console is immediately opened at the bottom of the VisualApplets program window:
Using the Scripting Console#
In the Scripting Console, you can switch in the Script Interpreter drop-down list, whether you want to use Python or Tcl as scripting language:
The Scripting Console has the following fields:
- Enter your command into the input field and strike the Return key.
-
In the scrollable log window above, all commands you have entered are displayed, together with information if the command could be carried out, and with according error messages if not. The Scripting Console lists all commands you enter for design creation (via GUI options, key strokes, or in Tcl/Python).
Commands you entered are marked by a preceding “>”.Errors are highlighted in red.
-
Use the Scripting Console to get information about commands and their syntax: Just carry out the action (you want to define in your script) using the GUI options of VisualApplets (clicking, Drag&Drop, key strokes …) and read in the log window of the Scripting Console how this action is defined in Tcl or Python. You can use Copy&Paste to copy commands into your script.
- Use the Scripting Console to test the commands you want to enter into your script: Just enter the command in the command input field and check if the desired action is carried out by VisualApplets. You can use Copy&Paste to copy a successful command into your script.
Info
The Scripting Console lists commands you enter for design creation: Not only commands you enter in Tcl/Python, but also commands you give by using the VisualApplets GUI options. This is very helpful when you start using scripts for VA designs, as you can easily get information about the correct commands and the according command syntax.
For a complete list of all VisualApplets-specific Tcl and Python commands, refer to the topics Tcl Command Reference and Python Command Reference.
Starting Scripts from the Scripting Console#
You have three options to start a script from the Scripting Console.
Info
Make sure the correct scripting language is selected in the Script Interpreter drop-down list box before importing the script.
Starting Scripts via the Toolbar#
You can start a script via the toolbar button Open Script:
Navigate to the directory where your script is located and select it.
Info
Make sure the correct scripting language is selected in the Script Interpreter drop-down list box before importing the script.
Starting Scripts Manually#
You can also type the Source
command manually:
Tcl Syntax:
- Type the command
Source
into the command input field. - Leave a space and type the path to the scripting file and the name of the scripting file directly after the command
Source
. If path or file name contain spaces, put path + file name into double quotes. - Strike the Return key to start executing the script in VisualApplets.
Python Syntax:
- Type the command
Source
into the command input field. -
Open a parenthesis and quotation marks and type the path to the scripting file and the name of the scripting file directly after the parenthesis and quotation marks. If path or file name contain spaces, put path + file name into double quotes. Close the quotation marks and parenthesis.
Example:
Source("C:/Basler/MyPythonScript.py")
-
Strike the Return key to start executing the script in VisualApplets.
Copying Scripting Code into the Console#
You can also simply copy Tcl or Python code from the clipboard into the command input field:
- Mark the code you want to execute in your script and copy it to the clipboard.
- Past the code from the clipboard into the command input field.
- Strike the Return key to start executing the code in VisualApplets.
Quick Command Syntax Information#
To get information about the syntax of a command very quickly:
- Enter the name of the command into the command input field, followed by:
- For Tcl:
<CommandName>
followed by a space and a question mark - For Python:
help(<CommandName>)
- For Tcl:
- Press Enter.
The syntax of the parameter is displayed in the Scripting Console window.
Tcl Example:
Enter GetModules ?
to get syntax information for command GetModules
.
The Scripting Console window displays the required information:
Python Example:
Enter help(GetModules)
to get syntax information for command GetModules
.
The Scripting Console window displays the required information:
For detailed information about individual parameters and allowed values, refer to topics TCL Command Reference and Python Command Reference.