Text mode for Scripts

About Text Mode

Using Text mode, you can set up the same scripts as Block mode scripts. Any operations supported by the screen editing software in Block mode scripts is also supported by Text mode scripts, such as mathematical operations (sine, cosine, etc.), logical operations (&&, ||, etc.) and comparison operations (==, !=, etc.). Scripts that are not listed in [Toolchest] are not supported.

Script Editor

In Text mode, the script editor divides the script into sections, with each script section having a trigger and one or more operations.

Triggers, such as Touch, Periodic/Schedule, and Conditional, take the form of a function. If a trigger requires parameters, pass them as function parameters.

Operations take the form of a statement with a semicolon (;) to end the statement.

The Text mode format is as shown in the following example.

Objects and Variables

Add a keyword to identify a referenced object or variable. Prefix the keyword with the '$' symbol. (Refer to the following table.)

Module Identifier

Keyword

Description Example
$Alarm To access an alarm property. $Alarm.AlarmGroup1.Var1_HiHi.Message
$AlarmGroup To access an alarm group property. $AlarmGroup.AlarmGroup1.CurrentActiveCount
$AllAlarm To access a property of all alarms. $AllAlarm.MaxRecord

$SystemErrorGroup

To identify as system error group.

 
$OperationLog To access an operation log property. $OperationLog.ExportData.FolderName
$RecipeControl To access a recipe control property. $RecipeControl.RecipeControl1.RecipeID
$Ingredient To access an ingredient property. $Ingredient.RecipeFamily1.RecipeGroup1.Ingredient1.Value
$Local To access a local variable property. $Local.Var1.Value
$GraphicObject To access a graphic object property. $GraphicObject.NumericDisplay1.CurrentValue
$Screen To access a screen property, or to access a property of an item on a specific screen. Use this identifier to avoid any potential screen/content and object naming conflicts. $Screen.Screen1
$Device To access a driver or equipment property. $Device.Driver1.Equipment1.OnScanMode
$Target To access a target property. $Target.Preferences.ColorSetID
$Math To access math operations. $Math.abs(-100)
$Enums To access operations and values you can specify with scripts, such as file operations and data formats. $Enums.FileOperation.CopyPaste $Enums.DataFormat.Float

By referencing objects and variables in a script, you can work with an object's or variable's properties. For example, 'Var1.Quality', '$GraphicObject.Ellipse1.Thickness'.

When you type the name of a graphical object, variable, alarm group, user group, logging group, or recipe in a script, the name is highlighted.

Changing Script Mode

In the script editor, you can use either [Block] mode or [Text] mode. You cannot edit scripts in both modes at the same time.

The default is [Block] mode.

To change the script mode, go to [Project] ➞ [Settings], then in the [Properties] window ➞ [Basic] ➞ [Script] ➞ [Script Mode], and select either [Block] or [Text].

Note: You cannot change the Script Mode if any of the script is invalid. However, you can change the Script Mode even if there is a data error.

Working with Scripts in Text Mode

Adding Functions

When working with scripts in Text mode, the Toolchest lists triggers, operations, logic, and expressions. Double-click a trigger and a new script section is created in the script editor along with the default code for the selected trigger.

You can also add functions using the following methods.
You can add a trigger from the tool bar.

Adding Source and Target

Toolchest

Comments

In Text mode, you can add comments to scripts with double slashes "//" and you can add multi-line comments in between "/*" and "*/". You can add comments at the end of a statement or on its own line.

Note:

  • When changing the [Script Mode] from [Block] to [Text] mode, Comment blocks are converted to "//" comments.

  • When changing the [Script Mode] from [Text] to [Block] mode:

    • "//" and "/*" "*/" comments at the Trigger level are converted to Comment blocks.

    • Other "//" statements or "/*" "*/" located outside the Trigger level are not converted as Block mode supports [Comment] blocks in Triggers only.

Find and Replace

The following table lists shortcut keys for Find and Replace operations.

Shortcut icon

Shortcut keys Description
Ctrl+F Find
Ctrl+H Find and Replace
F3 Find next
Shift+F3 Find previous
Alt+R Replace
Alt+A Replace all
Alt+C Match case
Alt+W Match whole word

You can toggle between Find and Replace, either entering the shortcut keys or clicking the up or down icon to the left of the [Find] field.

Restrictions

Script Mode

Names