The Scripts module allows you to write code for servers and clients in different languages such as C#, VB.NET, Python, and JavaScript. It offers valuable features, such as:
The Scripts module simplifies the development of solution by using server or client domains and ensuring high performance through the compilation of custom code.
On this page:
Below is a list of key concepts essential to understanding the Scripts Module.
A Script Task is a code that executes in reaction to an event (trigger) or periodically at specified intervals. For example, you can create a Task to execute every second or when any specific Tag in the Project has a new Value.
A Script Class is a library of functions and methods you can consume on Script Tasks, Expressions, or from the Code Behind on the graphical Displays. Using Scripts Classes allows a more efficient and clean organization of Project logic and calculations.
A Script Expression allows you to execute one line of code after an event. Instead of creating a Script Task, you can configure just one line at the Script Expressions table. For example, when one tag changes its value, and you want to set another tag value or call a Script Class, it is easier to define just the one-line Expression instead of a Task.
A Script Reference is an external DLL included for a script or display code compilation.
Script module configuration workflow | ||
---|---|---|
Action | Where | Comments |
Manage Class Scripts | Scripts→ Classes. Learn more at Script Classes. | |
Manage Task Scripts | Scripts→ Task. Learn more at Script Tasks. | |
Manage Expressions | Scripts→ Expressions. Learn more at Script Expressions. | |
Manage References | Scripts→ References. Learn more at Script References. | |
Track the module changes | Scripts→ Monitor. Learn more at Scripts Monitor. |
For a detailed understanding of the script execution process on the software framework, refer to the Scripts Runtime Execution and get insights into managing and optimizing scripts' performance.
The Scripts Monitor feature tracks and assesses script performance, providing crucial insights for optimizing your software platform. Dive into the Monitoring Scripts for an in-depth exploration of script monitoring techniques.
To read more about client-server programming in the software framework context, please explore Client-Server Programming.
To ensure the security and integrity of your data within the software framework, explore Client-Server Data Security. This resource provides detailed information on safeguarding data exchanges between clients and servers, protecting your project from potential security risks.
The Script module provides several built-in classes and methods libraries that can greatly streamline your project development process. If you're interested in leveraging the powerful built-in function libraries of software framework, see Built-in Methods and Libraries for detailed documentation.
The Historian module may encounter some issues in its operation. Here are some common issues and their troubleshooting:
Build Errors and Warnings: Make sure to check the 'BuildStatus' and 'BuildErrors' tabs to identify and address errors and warnings that arise during the build.
Code Language: If you change the code language in the code editor, confirm that the code has been correctly converted to the selected language.
Build Order: Ensure that the build order of the classes is set up correctly to avoid circular dependencies or initialization issues.
Domain Selection: Ensure that the domain is selected correctly (Client or Server) based on the needs of your project.
Expression Syntax: Check the syntax of the expressions, ensuring they comply with VB.Net or C# standards.
Execution Settings: Ensure that the execution settings are correct, so that the expressions are executed as expected.
Reference Issues: Make sure that all external references are configured correctly and that there are no compatibility issues or conflicts. Code Editor
Syntax Errors: Check for syntax errors in the code. Use the 'Auto Format' feature to identify potential issues.
Incremental Compilation Issues: Monitor the incremental compilation process to identify and resolve potential issues that may arise.
Debugger Setup: Ensure that the debugger setup is correct to allow effective code debugging.
Breakpoints and Watch Variables: Use breakpoints and watch variables effectively to identify and resolve issues.
Naming Convention: Use a coherent and descriptive naming convention to name the tasks.
Task Domain: Select the appropriate domain for each task, considering whether the task is more suitable for client-side or server-side execution.
Reusable Code: Promote code reuse through the creation of classes that encapsulate functionalities that can be reused in various parts of the project.
Expression Optimization: Write optimized expressions to ensure efficient execution and to reduce resource usage.
Library Management: Manage libraries and external components effectively to avoid conflicts and compatibility issues.
Code Consistency: Maintain code consistency by following best practices and coding conventions.
Build Before Deployment: Always perform a build operation before deploying a project in a production environment to ensure that all scripts are correct and up to date.
The Script namespace is the entry point for all objects related to the Scripts module.
The Script.Class object lists all configured tables and its runtime properties.
The Script.Task object lists all configured database connections and their runtime properties.
Examples:
Script Task properties | ||
---|---|---|
Property | Type | Description |
| Integer | Number of times the Script Task <Task1> was executed. |
| TimeSpan | The Amount of CPU used the last time the Script Task Task1 was executed. |
ModuleScript properties | ||
---|---|---|
Property | Type | Description |
| Boolean | Flag indicating if the module Dataset has started. |
| String | Message OK or error when initiating the module. |
See Namespaces Reference for the complete list of properties and available methods.
In this section: