Skip to main content
Version: Next

Scripts Reference

Complete reference for event types, actions, system commands, and troubleshooting.


Event Types Reference

Mouse Events (Component Only)

EventTrigger ConditionUse Case
ClickSingle left-clickButton actions, selection
Double ClickTwo rapid left-clicksOpen details, edit mode
Right ClickRight mouse buttonContext menus
Mouse DownMouse button pressedDrag start, custom interactions
Mouse UpMouse button releasedDrag end, release actions
Mouse EnterCursor enters componentHover effects, tooltips
Mouse LeaveCursor leaves componentHide tooltips, reset state
Mouse HoverCursor stays on componentDelayed tooltips, previews
Long PressButton held downAlternative actions
FocusComponent receives focusInput validation, highlighting
BlurComponent loses focusSave changes, validation

Lifecycle Events

EventScopeTrigger Condition
Component LoadComponentComponent is added to view
Component ExitComponentComponent is removed from view
View LoadViewView finishes loading
View ExitViewNavigating away from view
System StartupGlobalRuntime application starts

Tag Monitoring Events

Trigger Conditions:

ConditionDescriptionExample
Becomes TrueChanges from false/0/empty to true/non-zero/non-emptyAlarm activates
Becomes FalseChanges from true/non-zero/non-empty to false/0/emptyAlarm clears
True/False ChangeToggles between true and falseState changes
Value ChangeAny value changeCounter increments

Initialization Modes:

ModeBehaviorUse Case
Auto ExecuteExecute immediately on loadStartup initialization
Execute if MetExecute if condition is true on loadResume monitoring
DisabledDo not check on loadEvent-driven only

Expression Syntax:

Tag References:
Line1.Temperature
Line1.Temperature.Quality

Comparison:
Line1.Temperature > 80
Line1.Status == "Running"

Logical Operators:
Line1.Temp > 80 && Line1.Pressure < 5
Line1.Running || Line2.Running
!Line1.Alarm

Functions:
Math.Abs(Line1.Temp - Line2.Temp) > 5
Line1.Status.Contains("Error")
ProductCode.StartsWith("PROD")

Scheduled Task Events

Time Units:

  • Seconds
  • Minutes
  • Hours
  • Days

Configuration Parameters:

ParameterRequiredDescription
Start TimeYesWhen schedule begins
FrequencyYesInterval between executions
End TimeNoWhen schedule stops (empty = never)

Execution Behavior:

  • Uses natural time reference (not elapsed time)
  • Continues across application restarts
  • Requires application to remain in foreground

Example Schedules:

Every 30 seconds:
Frequency: 30 Seconds

Every hour on the hour:
Start Time: 2024-01-01 00:00:00
Frequency: 1 Hour

Every 8 hours (shift change):
Start Time: 2024-01-01 08:00:00
Frequency: 8 Hours

Daily at 2 AM:
Start Time: 2024-01-01 02:00:00
Frequency: 1 Day

Alarm Events

Alarm Trigger:

ParameterDescription
Alarm PointsOne or more alarm points to monitor
Trigger ConditionAny alarm point triggers
Execute on LoadCheck alarm state on startup

Alarm Recovery:

ParameterDescription
Alarm PointsOne or more alarm points to monitor
Recovery ModeAll recovered / Any recovered

Barcode Scan Events

Event Parameter:

  • event.code: Scanned barcode string

Supported Devices:

  • USB barcode scanners (keyboard emulation mode)

Example Usage:

Condition: event.code.Length == 13
Action: Query database WHERE Barcode = event.code

Broadcast Events

Configuration:

  • Broadcast Content: String to match (case-sensitive)

Usage Pattern:

Sender Event:
Action: Send Broadcast "RefreshData"

Receiver Event:
Event: Broadcast Event
Broadcast Content: "RefreshData"
Actions: Reload data, update display

Component-Specific Events

Input Change:

  • Applies To: Input controls (text box, dropdown, etc.)
  • Event Parameter: event.target.value
  • Trigger: User changes input value

Cell Selection:

  • Applies To: Table, Report components
  • Event Parameters:
    • event.cell.name: Selected cell field name
    • event.cell.value: Selected cell value
    • event.row.cells[index].name: Row cell field name
    • event.row.cells[index].value: Row cell value
  • Trigger: User clicks table cell

Action Types Reference

Component Actions

Layout & Size Actions

Resize:

ParameterTypeDescription
ModeEnumPercentage / Absolute
WidthNumber/TagNew width value
HeightNumber/TagNew height value

Move:

ParameterTypeDescription
ModeEnumRelative / Absolute
XNumber/TagX position or offset
YNumber/TagY position or offset

Rotate:

ParameterTypeDescription
ModeEnumRelative / Absolute
AngleNumber/TagRotation angle in degrees
Offset XNumber/TagRotation center X offset
Offset YNumber/TagRotation center Y offset

Text Actions

Text Style:

ParameterTypeDescription
ColorColorText color
Font SizeNumber/TagFont size in pixels
BoldBooleanBold text
ItalicBooleanItalic text
UnderlineBooleanUnderlined text
AlignmentEnumLeft / Center / Right
Letter SpacingNumber/TagSpace between characters
Line SpacingNumber/TagSpace between lines

Text Content:

ParameterTypeDescription
TextString/TagNew text content

⚠️ Caution: Not supported for components with functional text (charts, read/write controls, filters, etc.)

Appearance Actions

Background:

ParameterTypeDescription
ColorColorBackground color

Border:

ParameterTypeDescription
ColorColorBorder color
WidthNumber/TagBorder width in pixels
StyleEnumBorder line style

Shadow:

ParameterTypeDescription
ModeEnumOuter / Inner
HorizontalNumberHorizontal offset
VerticalNumberVertical offset
BlurNumberBlur radius
SizeNumberShadow size
ColorColorShadow color

Corner Radius:

ParameterTypeDescription
RadiusNumber/TagCorner radius in pixels

Visibility Actions

Show/Hide:

ParameterTypeDescription
ModeEnumShow / Hide / Toggle

Opacity:

ParameterTypeDescription
OpacityNumber/TagOpacity percentage (0-100)

Blink:

ParameterTypeDescription
ModeEnumStart / Stop
SpeedEnumSlow / Medium / Fast

Interaction Actions

Enable/Disable:

ParameterTypeDescription
ModeEnumEnable / Disable / Toggle

💡 Tip: Disabled components show a "not allowed" cursor and do not respond to events.

Trigger Event:

ParameterTypeDescription
EventEnumEvent to trigger on this component

⚠️ Caution: Avoid circular triggers (A→B→A) as they will cause errors.

Component-Specific Actions

Set Image (Image component):

ParameterTypeDescription
ImageAssetImage from asset library

Get Control Value to Tag (Input controls):

ParameterTypeDescription
TagTagTag to receive control value

Supported Components: Dropdown, Input Box, Time Picker, Numeric Input, Read/Write Box, Dropdown Control, Checkbox Control, Radio Control, Filter

Set Control Value (Input controls):

ParameterTypeDescription
ValueAny/TagValue to set in control

Supported Components: Dropdown, Input Box, Time Picker, Filter

Set Container View (View Container):

ParameterTypeDescription
ViewViewView to display in container

Set Quick Time Filter (Quick Time Filter):

ParameterTypeDescription
Time OptionEnumQuick time selection option

Set Relative Time Filter (Relative Time Filter):

ParameterTypeDescription
Relative OptionEnumPast / Future
Relative ValueNumber/TagTime value
Relative UnitEnumSeconds / Minutes / Hours / Days

View Actions

Navigate to View:

ParameterTypeDescription
Target ViewViewView to navigate to

Behavior:

  • Main window events: Switch main window view
  • Popup window events: Switch popup view
  • Global events: Switch main window view

Close View:

ParameterTypeDescription
(none)-Closes view(s)

Behavior:

  • Main window events: Close all popups
  • Popup window events: Close current popup
  • Global events: Close all popups

Reload View:

ParameterTypeDescription
(none)-Refreshes current view

Behavior:

  • Main window events: Reload main window
  • Popup window events: Reload current popup
  • Global events: Reload main window

Go Back:

ParameterTypeDescription
(none)-Return to previous view

Behavior:

  • Supports multiple levels of navigation history
  • Works independently for main window and popups

Popup View:

ParameterTypeDescription
Target ViewViewView to display in popup
TitleStringPopup window title
Fixed SizeBooleanUse custom size vs. auto-size
WidthNumberPopup width (if fixed size)
HeightNumberPopup height (if fixed size)
ModalEnumModal (blocks interaction) / Free (independent window)
Show Close ButtonBooleanShow X button in title bar

Export View:

ParameterTypeDescription
FormatEnumPDF / Image
Paper SizeEnumA4, Letter, etc. (PDF only)
LayoutEnumPortrait / Landscape (PDF only)
File NameStringFile name (supports {timestamp})
Save PathStringDirectory path (optional)

File Naming:

  • Supports dynamic naming: Report_{timestamp}
  • Timestamp format: YYYYMMDDHHmmss
  • If path not specified, user selects location

Print View:

ParameterTypeDescription
(none)-Send view to printer

Export Chart Data:

ParameterTypeDescription
Target ViewViewView containing the chart
Target ChartComponentChart component to export
FormatEnumExcel
ContentMulti-selectChart Data / Filter Conditions / Chart Style
File NameStringFile name (supports {timestamp})
Save PathStringDirectory path (optional)

⚠️ Caution: Target view must be currently displayed for export to work.

💡 Tip: Use forward slashes (/) in paths, not backslashes (\).

System Actions

System Notification:

ParameterTypeDescription
MessageString/TagNotification text
TypeEnumInfo / Warning / Error

Set Tag Value:

ParameterTypeDescription
TagTagTag to write to
ValueAny/TagValue to write

Wait:

ParameterTypeDescription
DurationNumberWait time in milliseconds

💡 Tip: Use Wait between actions that need sequential execution (e.g., write tag, wait, read tag).

Send Broadcast:

ParameterTypeDescription
Broadcast ContentStringBroadcast message identifier

Execute Script:

ParameterTypeDescription
ScriptScriptC# script to execute

Call API:

ParameterTypeDescription
APIAPI ConfigAPI endpoint from Bridge configuration

Data Table Operation:

ParameterTypeDescription
OperationEnumInsert / Update / Delete / Import / Export
TableTableTarget data table
ParametersVariesOperation-specific parameters

Supported Tables:

  • Bridge data tables
  • Data Management tables (variable historian, basic data tables)
  • Data Management aggregation tables (export only)

Query to Tags:

ParameterTypeDescription
QueryQuery ConfigDatabase query configuration
Tag MappingsMappingsField-to-tag assignments

Supported Sources:

  • Bridge data tables
  • Bridge data queries
  • Data Management system tables
  • Data Management variable historian
  • Data Management aggregation tables
  • Data Management basic data tables

Authentication:

ParameterTypeDescription
Auth MethodAuth ConfigCustom authentication method

💡 Tip: Requires custom development for extended authentication methods (RFID, biometric, etc.)

Virtual Keyboard:

ParameterTypeDescription
ModeEnumOpen / Close

Play Audio:

ParameterTypeDescription
ModeEnumPlay / Stop
Audio FileAssetAudio file from asset library
LoopBooleanRepeat playback

Switch Language:

ParameterTypeDescription
LanguageEnumTarget language

Exit Application:

ParameterTypeDescription
(none)-Close application with confirmation

⚠️ Caution: Only works in desktop client, not web browser.

Minimize:

ParameterTypeDescription
(none)-Minimize to system tray

Shutdown:

ParameterTypeDescription
(none)-Close application and shutdown computer

⚠️ Caution: Only works in desktop client, not web browser.

Recipe Actions

See Recipe Management guide for detailed information.

ActionDescription
Switch Recipe SetChange active recipe set
Switch to First RecipeLoad first recipe in set
Switch to Previous RecipeLoad previous recipe
Switch to Next RecipeLoad next recipe
Switch to Last RecipeLoad last recipe in set
Switch RecipeLoad specific recipe
Add RecipeCreate new recipe
Rename RecipeChange recipe name
Delete RecipeRemove recipe
Save RecipeSave current parameters
Read Parameters from TagsUpdate recipe from tag values
Apply RecipeApply recipe to equipment
Create CopyDuplicate current recipe

System Commands Reference

Built-in C# methods available in scripts.

Variable Operations

ReadTag:

object ReadTag(string tagName)

Description: Read current tag value

Parameters:

  • tagName: Full tag path (e.g., "Line1.Temperature")

Returns: Tag value (type depends on tag data type)

Example:

var temp = ReadTag("Line1.Temperature");
if ((double)temp > 80) {
// Handle high temperature
}

WriteTag:

void WriteTag(string tagName, object value)

Description: Write value to tag

Parameters:

  • tagName: Full tag path
  • value: Value to write (must match tag data type)

Example:

WriteTag("Line1.SetPoint", 75.0);
WriteTag("Line1.Running", true);
WriteTag("Line1.Status", "Active");

QueryHistorian:

DataTable QueryHistorian(string tagName, DateTime startTime, DateTime endTime)

Description: Query tag historian data for a time range

Parameters:

  • tagName: Full tag path
  • startTime: Start of time range
  • endTime: End of time range

Returns: DataTable with columns: Timestamp, Value, Quality

Example:

var start = DateTime.Now.AddHours(-1);
var end = DateTime.Now;
var data = QueryHistorian("Line1.Temperature", start, end);

foreach (DataRow row in data.Rows) {
var timestamp = (DateTime)row["Timestamp"];
var value = (double)row["Value"];
// Process historian data
}

Data Management Operations

QueryData:

DataTable QueryData(string tableName, string whereClause)

Description: Query data table records

Parameters:

  • tableName: Data table name (not table ID)
  • whereClause: SQL WHERE clause content (without "WHERE" keyword)

Returns: DataTable with query results

Example:

// Query all records
var allData = QueryData("ProductionLog", "");

// Query with condition
var todayData = QueryData("ProductionLog", "Date = '2024-01-15'");

// Query with multiple conditions
var filtered = QueryData("ProductionLog", "Shift = 'A' AND Output > 100");

InsertData:

void InsertData(string tableName, Dictionary<string, object> record)

Description: Insert a new record into data table

Parameters:

  • tableName: Data table name
  • record: Dictionary of field names and values

Example:

var record = new Dictionary<string, object>();
record["Date"] = DateTime.Now;
record["Shift"] = "A";
record["Output"] = 150;
record["Quality"] = 98.5;

InsertData("ProductionLog", record);

ClearData:

void ClearData(string tableName, string whereClause)

Description: Delete records from data table

Parameters:

  • tableName: Data table name
  • whereClause: SQL WHERE clause content (empty = delete all)

Example:

// Delete all records
ClearData("TempLog", "");

// Delete specific records
ClearData("ProductionLog", "Date < '2024-01-01'");

Expression Reference

Operators

Comparison Operators:

OperatorDescriptionExample
==Equal toStatus == "Running"
!=Not equal toStatus != "Stopped"
>Greater thanTemperature > 80
<Less thanPressure < 5
>=Greater than or equalCount >= 100
<=Less than or equalLevel <= 50

Logical Operators:

OperatorDescriptionExample
&&ANDTemp > 80 && Pressure < 5
``
!NOT!Running

Arithmetic Operators:

OperatorDescriptionExample
+AdditionValue1 + Value2
-SubtractionSetPoint - Actual
*MultiplicationCount * 2
/DivisionTotal / Count
%ModuloCount % 10

String Functions

FunctionDescriptionExample
.Contains(str)Check if contains substringStatus.Contains("Error")
.StartsWith(str)Check if starts withCode.StartsWith("PROD")
.EndsWith(str)Check if ends withFile.EndsWith(".csv")
.LengthGet string lengthCode.Length == 10
.ToUpper()Convert to uppercaseStatus.ToUpper() == "RUNNING"
.ToLower()Convert to lowercaseStatus.ToLower() == "running"

Math Functions

FunctionDescriptionExample
Math.Abs(x)Absolute valueMath.Abs(Deviation) > 5
Math.Max(x, y)Maximum of two valuesMath.Max(Temp1, Temp2)
Math.Min(x, y)Minimum of two valuesMath.Min(Temp1, Temp2)
Math.Round(x)Round to nearest integerMath.Round(Value)
Math.Floor(x)Round downMath.Floor(Value)
Math.Ceiling(x)Round upMath.Ceiling(Value)
Math.Sqrt(x)Square rootMath.Sqrt(Value)
Math.Pow(x, y)PowerMath.Pow(Base, Exponent)

Best Practices

Event Configuration

Naming Conventions:

  • Use descriptive names: "Temperature Alarm Response" not "Event1"
  • Include trigger condition: "High Temp > 80°C"
  • Indicate scope: "[Global] System Startup"

Event Organization:

  • Group related events together
  • Disable unused events instead of deleting
  • Document complex event logic with comments

Performance Optimization:

  • Use "Value Change" trigger for tag monitoring
  • Set appropriate scheduled task intervals
  • Avoid monitoring high-frequency tags

Condition Design

Expression Best Practices:

  • Keep expressions simple and readable
  • Use parentheses for complex logic: (A && B) || (C && D)
  • Test with edge cases (null, zero, empty)

Condition Reuse:

  • Use switch/case for multiple value checks
  • Combine related conditions with logical operators
  • Leverage event parameters to reduce complexity

Action Sequencing

Execution Order:

  • Place critical actions first
  • Use Wait actions for timing-dependent operations
  • Group related actions together

Error Handling:

  • Provide user feedback for important operations
  • Log errors for troubleshooting
  • Handle edge cases gracefully

Script Development

Code Quality:

  • Use meaningful variable names
  • Add comments for complex logic
  • Follow C# coding standards

Testing:

  • Test in development environment first
  • Verify with realistic data
  • Check error handling

Performance:

  • Avoid long-running operations
  • Cache frequently accessed data
  • Use efficient algorithms

Troubleshooting

Event Not Triggering

Problem: Event does not execute when expected.

Possible Causes:

  1. Event is disabled (toggle switch off)
  2. Event scope is incorrect (component/view/global)
  3. Event configuration is invalid

Solutions:

  1. Check event enable/disable status
  2. Verify event scope matches trigger location
  3. For tag monitoring:
    • Verify expression syntax
    • Check trigger condition (becomes true/false/change)
    • Confirm tag exists and has valid value
  4. For scheduled tasks:
    • Verify start time is in the past
    • Check frequency configuration
    • Ensure application is in foreground
  5. For alarm events:
    • Confirm alarm points are selected
    • Check if alarms are configured correctly

Condition Not Evaluating Correctly

Problem: Actions execute when they shouldn't (or vice versa).

Possible Causes:

  1. Expression syntax error
  2. Tag value type mismatch
  3. Logical operator precedence issue

Solutions:

  1. Open expression builder to validate syntax
  2. Check tag data types:
    • Use == for equality, not =
    • Compare strings with quotes: Status == "Running"
    • Use correct operators for numbers vs. strings
  3. Add parentheses for complex logic:
    • Wrong: A || B && C (ambiguous)
    • Right: A || (B && C) or (A || B) && C
  4. Test with known values:
    • Use System Notification to display tag values
    • Verify tag values match expectations

Actions Not Executing

Problem: Actions are configured but don't execute.

Possible Causes:

  1. Condition prevents execution
  2. Target component/view not available
  3. Action configuration error

Solutions:

  1. Check if condition is met:
    • Add System Notification before action to verify execution path
    • Temporarily remove condition to test actions
  2. Verify targets exist:
    • For component actions: Component must be on current view
    • For view actions: Target view must exist
    • For data operations: Table and fields must exist
  3. Check action parameters:
    • Verify tag names are correct
    • Ensure values match expected data types
    • Check file paths use forward slashes (/)
  4. Review execution order:
    • Ensure Wait actions are used where needed
    • Check if previous actions affect subsequent ones

Script Errors

Problem: Script action fails with error message.

Possible Causes:

  1. Syntax error in script
  2. Runtime error (null reference, type mismatch, etc.)
  3. API method called incorrectly

Solutions:

  1. Check script syntax:
    • Use script editor's syntax highlighting
    • Look for missing semicolons, brackets, quotes
  2. Add error handling:
    try {
    var value = ReadTag("Line1.Temperature");
    // Process value
    } catch (Exception ex) {
    // Log error or show notification
    }
  3. Verify API usage:
    • Check method signatures in documentation
    • Ensure parameters match expected types
    • Confirm tag/table names are correct
  4. Use debug output:
    var value = ReadTag("Line1.Temperature");
    ShowNotification("Temperature: " + value, "Info");

Performance Issues

Problem: Events execute slowly or cause lag.

Possible Causes:

  1. Too many active events
  2. High-frequency event triggers
  3. Long-running actions or scripts

Solutions:

  1. Reduce event count:
    • Disable unused events
    • Combine related events
    • Use broadcast events for coordination
  2. Optimize trigger frequency:
    • Use "Value Change" instead of continuous monitoring
    • Increase scheduled task intervals
    • Add debouncing for rapid events
  3. Optimize actions:
    • Move complex logic to scripts
    • Use asynchronous operations
    • Cache frequently accessed data
  4. Profile execution:
    • Add Wait actions to measure timing
    • Use System Notifications to track progress
    • Identify bottlenecks

Circular Event Triggers

Problem: Events trigger each other in a loop, causing errors.

Possible Causes:

  1. Event A triggers Event B, which triggers Event A
  2. Indirect circular trigger: A→B→C→A

Solutions:

  1. Review event chain:
    • Map out which events trigger which
    • Identify circular dependencies
  2. Break the loop:
    • Use broadcast events for coordination
    • Add conditions to prevent re-triggering
    • Redesign event flow
  3. Use flags:
    // In Event A
    if (ReadTag("EventARunning") == false) {
    WriteTag("EventARunning", true);
    // Execute actions
    WriteTag("EventARunning", false);
    }

Next Steps