Overview
You can write code in either standardThe Code Editor allow the user to write scripts in the following language:
- VB.NET
- C#
- Python
or C#. You can also switch between both. If you change your language selection in the code editor, the system automatically converts existing code to the selected language .For Python code, the editing is executed at the Python editor and a reference the program created is added.(only between VB.NET andC#).
On this page:
Table of Contents | ||||
---|---|---|---|---|
|
Editing Code
EditingTo edit code, follow the steps below:
Go to Scripts → CodeEditor.
- Access Scripts → Code Editor. The Code Editor environment displays the contents of the last selected Script Task or Script Class.
- Select the task or class you want to edit from
- the drop-down list in the main toolbar
- . See the Script Tasks or Script Classes pages for more details on creating tasks or classes.
- Select the Language in the toolbar.
- Edit the code.
If needed, select a different code language from the code editor toolbar.
- You can also format your code
Click Save.
When Selecting Scripts → CodeEditor, the Code Editor environment is displayed with the contents of the last selected Script Task or Script Class.
While in that environment, you can change the task or class you are editing using the ComboBox at the top area.
Scripts Compilation
The Scripts Compilation utilizes an incremental compilation approach, which means that scripts are automatically compiled in the background as they are created or modified without requiring explicit user intervention. This approach ensures that only the necessary scripts are compiled, resulting in improved performance and reduced compilation time.
When a script is created or modified, the incremental compilation mechanism identifies the affected scripts and compiles them individually rather than recompiling the entire project. This targeted compilation minimizes the overhead associated with compiling unchanged scripts, resulting in faster build times.
Before deploying a project into a production environment, it is highly recommended to execute a build operation. This build operation ensures that all scripts are up-to-date and compiled correctly, reducing the chances of runtime errors or unexpected behavior.
Info |
---|
When you use the code editor, the system constantly compiles code in the background. You can also build the whole project, as needed. For more information, see Running the Application. |
Productivity Enhancements
- for readability by clicking Auto Format.
- Click the floppy disk icon on the toolbar to save the changes.
The image below illustrates the process described above.
Productivity Tools
The Scripts Modules offers tools to enhance your productivity when creating and editing scripts. The are as follow:
IntelliSense: This is IntelliSense: it is a code-completion aid that features listing the available properties and methods for the objects and auto-completing their names. Additionally In addition to the Properties and Methods of the .NET Framework, it also supports all Project project entities, like Tags tags and Displaysdisplays. Just type Type a dot "(." ) after an element to show its available properties.
The Toolkit namespaceNamespace: our The platform exposes many .NET libraries to the applicationsolution, but there are a few methods that are frequently required, such as type conversion, copying tags to DataTables and .NET objects, or dynamically changing the communication settings, and others. Those methods are included in a library toolkit. To use these methods, you need to put use then insert TK. in the code editor. , IntelliSense will respond with a list of all available methods and provide a summary documentation for any method you select. Example:
d
ouble x = See the example below:Code Block double x = TK.ConvertTo<double>("123");
Access the namespace T.Toolkit.TK class at the Namespaces API to see the list of all methods available.
Scripts Compilation
The Scripts Compilation utilizes an incremental compilation approach, which means that scripts are automatically compiled in the background as they are created or modified without requiring explicit user intervention. This approach ensures that only the necessary scripts are compiled, resulting in improved performance and reduced compilation time. When a script is created or modified, the incremental compilation mechanism identifies the affected scripts and compiles them individually rather than recompiling the entire project. This targeted compilation minimizes the overhead of compiling unchanged scripts, resulting in faster build times.
When you use the code editor, the system constantly compiles code in the background. We recommend executing a build operation before deploying a project into a production environment. This build operation ensures that all scripts are up-to-date and compiled correctly, reducing the chances of runtime errors or unexpected behavior. For more information, see the Build and Publish page.
Debugging and Error Handling
Creating debugger InformationThe platform has an integrated .NET code debugger. In order to use it, the local computer must have a cache with the necessary files to run the debugger. The steps to enable the debugger are:
Enable the Debug Information on Runtime → Build and Publish.
As necessary, save the source code you want to debug. This will create the debug information. This step is only necessary the first time you open the project on the computer. Afterwards, the background compiling generates the necessary debugging information to enable the use of breakpoints and step execution.
Attaching the .NET debugger
In order to have a .NET debugging session, the engineering environment must be connected to the runtime , and the .NET debugger must be attached to server or client process. Follow these steps.
When Running the projectsolution, go to Runtime → Startup and enable the connect check box.
If the project solution is already running, go to Runtime → Startup, according to the runtime you want to attach, and connect to the runtime system by pressing the connect button on those pages.
Open any script that has debugging information and press the Attach .NET debugger button. A message on the bottom of the engineering workspace will show that a debugging session is active with the server components or the client components of the running project.
When the .NET debugger is attached, the system will stop on the defined breakpoints and will stop automatically when any .NET Exception occurs.
Breakpoints, Steps, and Watch
In order to setup a breakpoint, open the desired code, select the line, and press Insert Breakpoint on the toolbar.
When the system stops on a breakpoint, you can perform step by step execution or click the continue button.
In order to inspect local .NET variables, tags, or project objects, select the text in the script editor. When the execution is stopped on a breakpoint, the toolkit will show the current value of the variable.
You can also add .NET variables or project objects to the Watch window. When adding tags or project objects, you need to use the at symbols @, like @tag.tag1
. This will allow the system to know it is a project object and not a local .NET variable. Keep in mind that the Watch display is only updated when execution is stopped. If you want to have real-time values for tags and objects, open the PropertyWatch diagnostics tool.
In this section...
Page Tree | ||||
---|---|---|---|---|
|