Information:
For more information on JavaScript, please read http://www.w3schools.com/js/default.asp
Web Port scripts can also use methods in .NET provided they are called with a complete search path.
For more information on the .NET framework see
https://msdn.microsoft.com/en-us/library/aa139623.aspx
Call scripts are accessed from SYSTEM SETTINGS/SCRIPTS/CALL SCRIPTS. These can be called, among other things, from object functions and schedules.
Information:
To call a script, the following syntax is used:
script#script name(parameters).
Script names are read from the list of available CALL SCRIPTS
Parameters are not mandatory but are a good way to send information to the script.
Parameters are written as par1 = value, par2 = value where par1 and par2 become variables with set values in the script.
Example:
The following example calls the script sum with two parameters x=3 and y=5.
script#sum(x=3,y=5)
The following settings can be made for a called script:
Setting: | Description: |
*Name | Name of the called script (used for calls and must be unique) |
Description | Description of the function of the script and any parameters |
Code | Script code |
*mandatory parameter |
Create call script
Go to SYSTEM SETTINGS/SCRIPTS/CALL SCRIPTS. then NEW SCRIPT. Fill in settings according to table above and press SAVE.
Edit call script
Go to SYSTEM SETTINGS/SCRIPTS/CALL SCRIPTS. Click on the desired script in the list. Make the desired changes in the dialog that opens and press SAVE.
Delete call script
Go to SYSTEM SETTINGS/SCRIPTS/CALL SCRIPTS. Click on the desired script in the list. In the dialog that opens, press DELETE and then confirm to complete.
Call scripts in node/portal
When call scripts are used in a node connected to a portal it must be kept in mind that the script will be syncronized and also run in the portal. This creates the possible need for the script to consider that tags may have an additional prefix in the portal. To handle this in the script the variable nodeprefix is available. This will be an empty string in the node while it will will be set to the node prefix in the portal. See example below for how to use this.
Example:
Below example shows how the tag AS01_GT31_PV (which exists in the node) is read in a script which works in both node and portal (in the portal the prefix NODE1 is added → NODE1_AS01_GT31_PV)
Script code
var tag = nodeprefix == ”” ? ”AS01_GT31_PV” : nodeprefix +
”_AS01_GT31_PV”; var value = tagValue(tag);
External call of the called script
A called script can be called by external services via a URL. For a called script to be called, "Allow script calls" must be enabled for the connection that calls the script (SYSTEM SETTINGS/ACCESS/CONNECTIONS).
Information:
To call a script externally, the following URL and syntax are used:
http://webportaddress:8090/script/run?type=callscript&id=scriptid&par1=???&par2=???
scriptID is the name of the script to be called
&Par1=??? And &par2=??? are optional parameters that can be sent to the script.
The reply given when calling is what the script returns from the return statement.
To be able to call an external script, the script name must not contain any special characters.