The script is Scripts are divided into two parts: Declaration Part and Program Part. The declaration part is for the declaration of internal variables and input parameters. The program part includes all program statements except for the declarationvariable declarations.
Comments can be entered anywhere in the program. The strings Strings starting with ‘//’ are treated as comments until the end of the line.
...
Item | Description |
Variable Declaration | Declares the Declare internal variables in using the following format: VAR variable_name [, variable_name];. The initial value of the declared variables is 0. To declare more than one variable, use a comma “ , ” between them. variables: VAR variable_name_1, variable_name_2, … , variable_name_n; You can use several multiple VAR keywords before the program part starts. The variable name cannot be duplicated with the Variable names cannot share the same names as tag names (Group, Digital, Analog, or String tags). The duplicated name Duplicate names may cause compile compiler errors or incorrect operation. |
Input Parameter Declaration | Declares the Declare input parameters in using the following format: PARAM 1st parameter [, 2nd parameter …]; .The input parameter is required Input parameters are used when a program is called by another program or a command. The declaration order must be identical to the order of input parameters. The parameter parameters will be initialized with the values assigned by the caller. To declare more than one parameter, use a comma “ , ” between them. You can use several PARAM keywords before the program part starts. |
Example | //Program Name: MyPgm VAR a, b; VAR c; PARAM p1, p2; PARAM p3;
The program MyPgm can be called by the external caller as shown below.: MyPgm(1,2,3); In the parameter p1, p2, p3, assigned The values (1, 2, and 3) will be stored in the parameters p1, p2, and p3, respectively. The variables a, b, and c, will be initialized as 0. |
...
In the program part, all program statements except the declaration (variables and parameters) can be used. The An example of the most basic statement is the function call, calculation, and storing the result.
The following program example is composed of basic statements.
...
Each statement must end with a semicolon “ ; ”. Each function returns a single result to the caller. The program mentioned shown above returns the result of MyPgm to “Tag_b”.
(3) Constants
When you use constants in the program, you can use the notations as shown below.
Item | Description |
Octal Constants | Only used Base 8; digits only range from 0 to 7. The octal constant Octal constants must start with 0. (E.g. 01277) |
Decimal Constants | General The general notation is used. (E.g. 153, 3.14, 2.45E-12) |
Hexadecimal Constants | It must Base 16. Must start with ‘0x’. Use the alphabet or number characters between ‘0’ and ‘F’. (E.g. 0xFFFF) |
String Constants | Enter the string between the Strings must be between two double-quotation marks (“ ”). (E.g. “String Variable1”) |
...
Constant Name | Value | Usage |
_PI_ | 3.141592… | 3.141592… (Value of π) |
_LOCAL_ | 0 | Local Flash Memory |
_SDMEM_ | 1 | SD/MMC Memory |
_USBMEM_ | 2 | USB Memory |
_COM232_ | 0 | Uses COM1 port as RS232C mode. |
_COM422_ | 1 | Uses COM1 port as RS422 mode. |
_COM485_ | 2 | Uses COM1 port as RS485 mode. |
_COMAUX_ | 3 | Uses COM2 port as RS232C mode only. |
_BPS300_ |
| 300 bps |
_BPS600_ |
| 600bps |
_BPS1200_ |
| 1200bps |
_BPS2400_ |
| 2400bps |
_BPS4800_ |
| 4800bps |
_BPS9600_ |
| 9600bps |
_BPS19200_ |
| 19200bps |
_BPS38400_ |
| 38400bps |
_BPS56000_ |
| 56000bps |
_BPS57600_ |
| 57600bps |
_BPS115200_ |
| 115200bps |
_BPS128000_ |
| 128000bps |
_BPS256000_ |
| 256000bps |
_PARITY_NONE_ |
| No parity |
_PARITY_EVEN_ |
| Even parity |
_PARITY_ODD_ |
| Odd parity |
_PARITY_MARK_ |
| Mark parity |
_PARITY_SPACE_ |
| Space parity |
_STOPBIT_ONE_ |
| 1 stop bit |
_STOPBIT_TWO_ |
| 2 stop bits |
_STOPBIT_ONE5_ |
| 1.5 stop bit |
_ALMPRT_ALL_ |
| Prints all items of alarm data. |
_ALMPRT_TIME_ |
| Prints the time of alarm data. |
_ALMPRT_ADDR_ |
| Prints the address of the alarm point. |
_ALMPRT_VALUE_ |
| Prints the value of the alarm. |
_ALMPRT_TYPE_ |
| Prints the alarm type. |
_ALMPRT_DESC_ |
| Prints the alarm description. |
_UINT_ |
| Unsinged integer |
_INT_ |
| Singed integer |
_FLOAT_ |
| Floating point value |
_HEX_ |
| Hexa-decimal number |
_EXP_ |
| Real number with an exponent |