Usefull Features

The inSCADA platform includes tools and methods that make it easy for developers and users. These features have been developed to increase your productivity on a comfortable platform.

Code2Form

Code2Form is a feature that you can use on all forms where you write script / expression on the inSCADA platform. Thanks to this feature, you can make your script / expressions parametric and select their parameters through the form and prevent you to make changes in the coding each time. Reduces your risk of making mistakes. Makes your Script / Expressions more portable.

As shown in Figure 1, when you open the script editor, you can see the javascript codes if the Code button is enabled. Let's examine the sample code of the form below.

function example() {
    
    var frm_anytag='{#tag:Tags}';
    var frm_text='{#text:Description}';
    var frm_on_color='{#combo:Energized:["GREEN","LIME"]}';
    
    var anytag=ins.getVariableValue(frm_anytag);
    if (anytag!==null) {
        return frm_text+" "+ anytag.value+" "+frm_on_color;
    }
    return "NOK";
}

example();

When we examine the above code, some definitions are made in {}. These are the definitions that make up the elements of our form when we press the Code button and switch the form mode. With these definitions, we enable the user to input the parameters in the form view that we want to use during the execution of our javascript code.

{#tag: Tags} returns all variables as a combobox on the form and allows the user to select them.

{#tag: Description} allows the user to enter a string to a textedit on the form.

{#combo: Energized: ["GREEN", "LIME"]} lists the options defined in the expression in a combobox on the form and allows the user to select any of them.

As can be seen in Figure 2, in the form mode, the user is no longer on the javascript code, but in a form where the user can select and edit the parameters needed.

Last updated