Scripts Reference
Complete reference for event types, actions, system commands, and troubleshooting.
Event Types Reference
Mouse Events (Component Only)
| Event | Trigger Condition | Use Case |
|---|---|---|
| Click | Single left-click | Button actions, selection |
| Double Click | Two rapid left-clicks | Open details, edit mode |
| Right Click | Right mouse button | Context menus |
| Mouse Down | Mouse button pressed | Drag start, custom interactions |
| Mouse Up | Mouse button released | Drag end, release actions |
| Mouse Enter | Cursor enters component | Hover effects, tooltips |
| Mouse Leave | Cursor leaves component | Hide tooltips, reset state |
| Mouse Hover | Cursor stays on component | Delayed tooltips, previews |
| Long Press | Button held down | Alternative actions |
| Focus | Component receives focus | Input validation, highlighting |
| Blur | Component loses focus | Save changes, validation |
Lifecycle Events
| Event | Scope | Trigger Condition |
|---|---|---|
| Component Load | Component | Component is added to view |
| Component Exit | Component | Component is removed from view |
| View Load | View | View finishes loading |
| View Exit | View | Navigating away from view |
| System Startup | Global | Runtime application starts |
Tag Monitoring Events
Trigger Conditions:
| Condition | Description | Example |
|---|---|---|
| Becomes True | Changes from false/0/empty to true/non-zero/non-empty | Alarm activates |
| Becomes False | Changes from true/non-zero/non-empty to false/0/empty | Alarm clears |
| True/False Change | Toggles between true and false | State changes |
| Value Change | Any value change | Counter increments |
Initialization Modes:
| Mode | Behavior | Use Case |
|---|---|---|
| Auto Execute | Execute immediately on load | Startup initialization |
| Execute if Met | Execute if condition is true on load | Resume monitoring |
| Disabled | Do not check on load | Event-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:
| Parameter | Required | Description |
|---|---|---|
| Start Time | Yes | When schedule begins |
| Frequency | Yes | Interval between executions |
| End Time | No | When 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:
| Parameter | Description |
|---|---|
| Alarm Points | One or more alarm points to monitor |
| Trigger Condition | Any alarm point triggers |
| Execute on Load | Check alarm state on startup |
Alarm Recovery:
| Parameter | Description |
|---|---|
| Alarm Points | One or more alarm points to monitor |
| Recovery Mode | All 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 nameevent.cell.value: Selected cell valueevent.row.cells[index].name: Row cell field nameevent.row.cells[index].value: Row cell value
- Trigger: User clicks table cell
Action Types Reference
Component Actions
Layout & Size Actions
Resize:
| Parameter | Type | Description |
|---|---|---|
| Mode | Enum | Percentage / Absolute |
| Width | Number/Tag | New width value |
| Height | Number/Tag | New height value |
Move:
| Parameter | Type | Description |
|---|---|---|
| Mode | Enum | Relative / Absolute |
| X | Number/Tag | X position or offset |
| Y | Number/Tag | Y position or offset |
Rotate:
| Parameter | Type | Description |
|---|---|---|
| Mode | Enum | Relative / Absolute |
| Angle | Number/Tag | Rotation angle in degrees |
| Offset X | Number/Tag | Rotation center X offset |
| Offset Y | Number/Tag | Rotation center Y offset |
Text Actions
Text Style:
| Parameter | Type | Description |
|---|---|---|
| Color | Color | Text color |
| Font Size | Number/Tag | Font size in pixels |
| Bold | Boolean | Bold text |
| Italic | Boolean | Italic text |
| Underline | Boolean | Underlined text |
| Alignment | Enum | Left / Center / Right |
| Letter Spacing | Number/Tag | Space between characters |
| Line Spacing | Number/Tag | Space between lines |
Text Content:
| Parameter | Type | Description |
|---|---|---|
| Text | String/Tag | New text content |
⚠️ Caution: Not supported for components with functional text (charts, read/write controls, filters, etc.)
Appearance Actions
Background:
| Parameter | Type | Description |
|---|---|---|
| Color | Color | Background color |
Border:
| Parameter | Type | Description |
|---|---|---|
| Color | Color | Border color |
| Width | Number/Tag | Border width in pixels |
| Style | Enum | Border line style |
Shadow:
| Parameter | Type | Description |
|---|---|---|
| Mode | Enum | Outer / Inner |
| Horizontal | Number | Horizontal offset |
| Vertical | Number | Vertical offset |
| Blur | Number | Blur radius |
| Size | Number | Shadow size |
| Color | Color | Shadow color |
Corner Radius:
| Parameter | Type | Description |
|---|---|---|
| Radius | Number/Tag | Corner radius in pixels |
Visibility Actions
Show/Hide:
| Parameter | Type | Description |
|---|---|---|
| Mode | Enum | Show / Hide / Toggle |
Opacity:
| Parameter | Type | Description |
|---|---|---|
| Opacity | Number/Tag | Opacity percentage (0-100) |
Blink:
| Parameter | Type | Description |
|---|---|---|
| Mode | Enum | Start / Stop |
| Speed | Enum | Slow / Medium / Fast |
Interaction Actions
Enable/Disable:
| Parameter | Type | Description |
|---|---|---|
| Mode | Enum | Enable / Disable / Toggle |
💡 Tip: Disabled components show a "not allowed" cursor and do not respond to events.
Trigger Event:
| Parameter | Type | Description |
|---|---|---|
| Event | Enum | Event to trigger on this component |
⚠️ Caution: Avoid circular triggers (A→B→A) as they will cause errors.
Component-Specific Actions
Set Image (Image component):
| Parameter | Type | Description |
|---|---|---|
| Image | Asset | Image from asset library |
Get Control Value to Tag (Input controls):
| Parameter | Type | Description |
|---|---|---|
| Tag | Tag | Tag 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):
| Parameter | Type | Description |
|---|---|---|
| Value | Any/Tag | Value to set in control |
Supported Components: Dropdown, Input Box, Time Picker, Filter
Set Container View (View Container):
| Parameter | Type | Description |
|---|---|---|
| View | View | View to display in container |
Set Quick Time Filter (Quick Time Filter):
| Parameter | Type | Description |
|---|---|---|
| Time Option | Enum | Quick time selection option |
Set Relative Time Filter (Relative Time Filter):
| Parameter | Type | Description |
|---|---|---|
| Relative Option | Enum | Past / Future |
| Relative Value | Number/Tag | Time value |
| Relative Unit | Enum | Seconds / Minutes / Hours / Days |
View Actions
Navigate to View:
| Parameter | Type | Description |
|---|---|---|
| Target View | View | View 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:
| Parameter | Type | Description |
|---|---|---|
| (none) | - | Closes view(s) |
Behavior:
- Main window events: Close all popups
- Popup window events: Close current popup
- Global events: Close all popups
Reload View:
| Parameter | Type | Description |
|---|---|---|
| (none) | - | Refreshes current view |
Behavior:
- Main window events: Reload main window
- Popup window events: Reload current popup
- Global events: Reload main window
Go Back:
| Parameter | Type | Description |
|---|---|---|
| (none) | - | Return to previous view |
Behavior:
- Supports multiple levels of navigation history
- Works independently for main window and popups
Popup View:
| Parameter | Type | Description |
|---|---|---|
| Target View | View | View to display in popup |
| Title | String | Popup window title |
| Fixed Size | Boolean | Use custom size vs. auto-size |
| Width | Number | Popup width (if fixed size) |
| Height | Number | Popup height (if fixed size) |
| Modal | Enum | Modal (blocks interaction) / Free (independent window) |
| Show Close Button | Boolean | Show X button in title bar |
Export View:
| Parameter | Type | Description |
|---|---|---|
| Format | Enum | PDF / Image |
| Paper Size | Enum | A4, Letter, etc. (PDF only) |
| Layout | Enum | Portrait / Landscape (PDF only) |
| File Name | String | File name (supports {timestamp}) |
| Save Path | String | Directory path (optional) |
File Naming:
- Supports dynamic naming:
Report_{timestamp} - Timestamp format:
YYYYMMDDHHmmss - If path not specified, user selects location
Print View:
| Parameter | Type | Description |
|---|---|---|
| (none) | - | Send view to printer |
Export Chart Data:
| Parameter | Type | Description |
|---|---|---|
| Target View | View | View containing the chart |
| Target Chart | Component | Chart component to export |
| Format | Enum | Excel |
| Content | Multi-select | Chart Data / Filter Conditions / Chart Style |
| File Name | String | File name (supports {timestamp}) |
| Save Path | String | Directory 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:
| Parameter | Type | Description |
|---|---|---|
| Message | String/Tag | Notification text |
| Type | Enum | Info / Warning / Error |
Set Tag Value:
| Parameter | Type | Description |
|---|---|---|
| Tag | Tag | Tag to write to |
| Value | Any/Tag | Value to write |
Wait:
| Parameter | Type | Description |
|---|---|---|
| Duration | Number | Wait time in milliseconds |
💡 Tip: Use Wait between actions that need sequential execution (e.g., write tag, wait, read tag).
Send Broadcast:
| Parameter | Type | Description |
|---|---|---|
| Broadcast Content | String | Broadcast message identifier |
Execute Script:
| Parameter | Type | Description |
|---|---|---|
| Script | Script | C# script to execute |
Call API:
| Parameter | Type | Description |
|---|---|---|
| API | API Config | API endpoint from Bridge configuration |
Data Table Operation:
| Parameter | Type | Description |
|---|---|---|
| Operation | Enum | Insert / Update / Delete / Import / Export |
| Table | Table | Target data table |
| Parameters | Varies | Operation-specific parameters |
Supported Tables:
- Bridge data tables
- Data Management tables (variable historian, basic data tables)
- Data Management aggregation tables (export only)
Query to Tags:
| Parameter | Type | Description |
|---|---|---|
| Query | Query Config | Database query configuration |
| Tag Mappings | Mappings | Field-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:
| Parameter | Type | Description |
|---|---|---|
| Auth Method | Auth Config | Custom authentication method |
💡 Tip: Requires custom development for extended authentication methods (RFID, biometric, etc.)
Virtual Keyboard:
| Parameter | Type | Description |
|---|---|---|
| Mode | Enum | Open / Close |
Play Audio:
| Parameter | Type | Description |
|---|---|---|
| Mode | Enum | Play / Stop |
| Audio File | Asset | Audio file from asset library |
| Loop | Boolean | Repeat playback |
Switch Language:
| Parameter | Type | Description |
|---|---|---|
| Language | Enum | Target language |
Exit Application:
| Parameter | Type | Description |
|---|---|---|
| (none) | - | Close application with confirmation |
⚠️ Caution: Only works in desktop client, not web browser.
Minimize:
| Parameter | Type | Description |
|---|---|---|
| (none) | - | Minimize to system tray |
Shutdown:
| Parameter | Type | Description |
|---|---|---|
| (none) | - | Close application and shutdown computer |
⚠️ Caution: Only works in desktop client, not web browser.
Recipe Actions
See Recipe Management guide for detailed information.
| Action | Description |
|---|---|
| Switch Recipe Set | Change active recipe set |
| Switch to First Recipe | Load first recipe in set |
| Switch to Previous Recipe | Load previous recipe |
| Switch to Next Recipe | Load next recipe |
| Switch to Last Recipe | Load last recipe in set |
| Switch Recipe | Load specific recipe |
| Add Recipe | Create new recipe |
| Rename Recipe | Change recipe name |
| Delete Recipe | Remove recipe |
| Save Recipe | Save current parameters |
| Read Parameters from Tags | Update recipe from tag values |
| Apply Recipe | Apply recipe to equipment |
| Create Copy | Duplicate 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 pathvalue: 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 pathstartTime: Start of time rangeendTime: 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 namerecord: 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 namewhereClause: 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:
| Operator | Description | Example |
|---|---|---|
== | Equal to | Status == "Running" |
!= | Not equal to | Status != "Stopped" |
> | Greater than | Temperature > 80 |
< | Less than | Pressure < 5 |
>= | Greater than or equal | Count >= 100 |
<= | Less than or equal | Level <= 50 |
Logical Operators:
| Operator | Description | Example |
|---|---|---|
&& | AND | Temp > 80 && Pressure < 5 |
| ` | ` | |
! | NOT | !Running |
Arithmetic Operators:
| Operator | Description | Example |
|---|---|---|
+ | Addition | Value1 + Value2 |
- | Subtraction | SetPoint - Actual |
* | Multiplication | Count * 2 |
/ | Division | Total / Count |
% | Modulo | Count % 10 |
String Functions
| Function | Description | Example |
|---|---|---|
.Contains(str) | Check if contains substring | Status.Contains("Error") |
.StartsWith(str) | Check if starts with | Code.StartsWith("PROD") |
.EndsWith(str) | Check if ends with | File.EndsWith(".csv") |
.Length | Get string length | Code.Length == 10 |
.ToUpper() | Convert to uppercase | Status.ToUpper() == "RUNNING" |
.ToLower() | Convert to lowercase | Status.ToLower() == "running" |
Math Functions
| Function | Description | Example |
|---|---|---|
Math.Abs(x) | Absolute value | Math.Abs(Deviation) > 5 |
Math.Max(x, y) | Maximum of two values | Math.Max(Temp1, Temp2) |
Math.Min(x, y) | Minimum of two values | Math.Min(Temp1, Temp2) |
Math.Round(x) | Round to nearest integer | Math.Round(Value) |
Math.Floor(x) | Round down | Math.Floor(Value) |
Math.Ceiling(x) | Round up | Math.Ceiling(Value) |
Math.Sqrt(x) | Square root | Math.Sqrt(Value) |
Math.Pow(x, y) | Power | Math.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:
- Event is disabled (toggle switch off)
- Event scope is incorrect (component/view/global)
- Event configuration is invalid
Solutions:
- Check event enable/disable status
- Verify event scope matches trigger location
- For tag monitoring:
- Verify expression syntax
- Check trigger condition (becomes true/false/change)
- Confirm tag exists and has valid value
- For scheduled tasks:
- Verify start time is in the past
- Check frequency configuration
- Ensure application is in foreground
- 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:
- Expression syntax error
- Tag value type mismatch
- Logical operator precedence issue
Solutions:
- Open expression builder to validate syntax
- Check tag data types:
- Use
==for equality, not= - Compare strings with quotes:
Status == "Running" - Use correct operators for numbers vs. strings
- Use
- Add parentheses for complex logic:
- Wrong:
A || B && C(ambiguous) - Right:
A || (B && C)or(A || B) && C
- Wrong:
- 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:
- Condition prevents execution
- Target component/view not available
- Action configuration error
Solutions:
- Check if condition is met:
- Add System Notification before action to verify execution path
- Temporarily remove condition to test actions
- 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
- Check action parameters:
- Verify tag names are correct
- Ensure values match expected data types
- Check file paths use forward slashes (/)
- 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:
- Syntax error in script
- Runtime error (null reference, type mismatch, etc.)
- API method called incorrectly
Solutions:
- Check script syntax:
- Use script editor's syntax highlighting
- Look for missing semicolons, brackets, quotes
- Add error handling:
try {
var value = ReadTag("Line1.Temperature");
// Process value
} catch (Exception ex) {
// Log error or show notification
} - Verify API usage:
- Check method signatures in documentation
- Ensure parameters match expected types
- Confirm tag/table names are correct
- Use debug output:
var value = ReadTag("Line1.Temperature");
ShowNotification("Temperature: " + value, "Info");
Performance Issues
Problem: Events execute slowly or cause lag.
Possible Causes:
- Too many active events
- High-frequency event triggers
- Long-running actions or scripts
Solutions:
- Reduce event count:
- Disable unused events
- Combine related events
- Use broadcast events for coordination
- Optimize trigger frequency:
- Use "Value Change" instead of continuous monitoring
- Increase scheduled task intervals
- Add debouncing for rapid events
- Optimize actions:
- Move complex logic to scripts
- Use asynchronous operations
- Cache frequently accessed data
- 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:
- Event A triggers Event B, which triggers Event A
- Indirect circular trigger: A→B→C→A
Solutions:
- Review event chain:
- Map out which events trigger which
- Identify circular dependencies
- Break the loop:
- Use broadcast events for coordination
- Add conditions to prevent re-triggering
- Redesign event flow
- Use flags:
// In Event A
if (ReadTag("EventARunning") == false) {
WriteTag("EventARunning", true);
// Execute actions
WriteTag("EventARunning", false);
}
Next Steps
- Understanding Scripts: Learn about the Scripts system architecture
- Creating Event-Actions: Step-by-step guide to configuring events
- Understanding Tags: Work with tags in scripts and events
- Understanding Data Management: Query and manipulate data tables
Related Topics
- Creating Alarms: Configure alarm-triggered events
- Creating Views: Design interactive views with events
- Tags Reference: Tag data types and quality codes