Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Current »

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 variable declarations.

Comments can be entered anywhere in the program. Strings starting with ‘//’ are treated as comments until the end of the line.

 (1) Declaration Part

Item

Description

Variable Declaration

Declare internal variables using the following format:

VAR variable_name;

The initial value of declared variables is 0. To declare more than one variable, use a comma “ , ” between variables:

VAR variable_name_1, variable_name_2,, variable_name_n;

You can use multiple VAR keywords before the program part starts.

Variable names cannot share the same names as tag names (Group, Digital, Analog, or String tags). Duplicate names may cause compiler errors or incorrect operation.

Input Parameter Declaration

Declare input parameters using the following format:

PARAM 1st parameter [, 2nd parameter …];

Input parameters are used when a program is called by another program or command. The declaration order must be identical to the order of input parameters. The 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);

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.

 (2) Program part

In the program part, all program statements except the declaration (variables and parameters) can be used. 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.

Tag_a = Tag_a + 1;

Tag_b = MyPgm(Tag_a, 2, 3);

Each statement must end with a semicolon “ ; ”. Each function returns a single result to the caller. The program 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

Base 8; digits only range from 0 to 7. Octal constants must start with 0. (E.g. 01277)

Decimal Constants

The general notation is used. (E.g. 153, 3.14, 2.45E-12)

Hexadecimal Constants

Base 16. Must start with ‘0x’. Use the alphabet or number characters between ‘0’ and ‘F’. (E.g. 0xFFFF)

String Constants

Strings must be between two double-quotation marks (“ ”). (E.g. “String Variable1”)

You can also utilize the predefined constants as shown below.

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

 


 

  • No labels