l Assigning a Tag Name to a Generic Name
5.2 Group Assignment Statement
Data designated as a list of variables or constants on the right-hand side are set in the list of variables on the left-hand side.
n
Usage of Group Assignment Statement
[<variable list>=<variable or constant list>]
[<error array> [*] ] [; error <label> [, <error identifier>] ] errorsub
<variables list> This is a list of assigned variables. A maximum of 32 variables can be designated. For arrays, each array element is counted as one. <variable or constants list>
Designate a list of constants or variables of the type corresponding to the assigned variables.
<error array> Designate an integer-type local variable array for storing error codes when an error is generated while reading a variable on the right-hand side or writing to a variable on the left-hand side.
When errors occur both on the left and right sides, the error code for the error occurring on the right-hand side is stored in the error array. Omit the error array if it is not necessary to check errors in individual data. When there is only one data to be assigned, a local simple variable or array element can be designated in the error array.
If an <error array> is described, a 0 during normal operation and the error code when an error occurs, is set in the related array element so that it is possible to specify which function block data was being accessed at the time the error occurred.
<label> Designate the branching destination at the time an error occurs. <error identifier> Designate a local variable or a constant to identify where the error was
generated in the error handling section.
If an <error identifier> is described, the location where the error occurred can be identified in the error handling section. In the error handling section, an <error identifier> value can be obtained using a built-in function.
Figure 5.2-1 The format of the group assignment statement
When assigning data in a group to data in multiple function blocks, the data is set in the order in which the variable list is designated. However, the only instance where the order of data setting can be guaranteed is for function block data in the same FCS.
SEE
ALSO For more information about error handling, refer to: 13., “Error Handling” on page 13-1
l
List of Variables that can be Designated on Both Sides of a Group
Assignment Statement
Designate constants, local variables or a list of function block data variables on the left- and right-hand sides of a group assignment statement.
Table 5.2-1 Variables that Can be Designated in a Variable List
Constant, local variable, function block data Assignment statement Left Right
Constant No Yes
<5.2 Group Assignment Statement>
5-10
Constant, local variable, function block data Assignment statement Left Right
Variable in a local variable Yes Yes
Local variable array element Yes Yes
Local variable array Yes Yes
Tag name+Data item name Yes Yes
Simple variable in a local generic name+Data item name Yes Yes
Local generic name array element+Data item name Yes Yes
Local generic name array+Data item name Yes Yes
Simple variable in a function-block dummy argument+Data item name Yes Yes Function-block dummy argument array element+Data item name Yes Yes
Function-block dummy argument array+Data item name Yes Yes
l
How to Describe a Function Block Array
In a group assignment statement, the function block array can be described in the expression or on the left-hand side of the statement. However, it cannot be described in the format, [func- tion block array.data item array element].
In a group assignment statement, a maximum of 32 data can be manipulated in one state- ment. When an array is designated, the number of data becomes the number of elements in the array.
Table 5.2-2 Syntax of a Function Block Array
Function block Data item Example of description
Entire array Simple variable GEN01[*].PV
Entire array Array element Cannot be used
l
Usage of Function Block Data in a Variable List
Each of the variables or constants in a variable list are delimited with a [,] (comma) when de- scribed. When simultaneously accessing multiple data items in a function block, the multiple data item names are delimited with a [.] (period) and designated.
<tag name>. <data item name> [.<data item name>...]
<local generic name>. <data item name> [.<data item name>...]
<function-block dummy argument>. <data item name> [.<data item name>...] <local generic name array element>. <data item name> [.<data item name>...]
<function-block dummy argument array element>. <data item name> [.<data item name>...] • SFC block data
%.<data item name> [.<data item name>...] • Unit instrument data
%%.<data item name> [.<data item name>...] • Array
<local generic name array> [*]. <data item name> [.<data item name>...]
<function-block dummy argument array>[*]. <data item name> [.<data item name>...] In an array, the following descriptions with [*] omitted are possible.
<local generic name array>. <data item name> [.<data item name>...]
<function-block dummy argument array>. <data item name> [.<data item name>...]
Figure 5.2-2 The format of the function block data in a variable list
TIP • Enter in “<tag name>” a tag name that is declared in the “block” or “global block” statement.
• Where a local variable can be used, a dummy argument local variable can also be used.
• Where a local generic name can be used, a generic name or dummy argument function block can also be used.
l
Checking the Number of Data on the Left- and Right-Hand Sides of a
Group Assignment Statement
The following checks are performed during compilation when the number of data on the left- and right-hand sides of a group assignment statement differ, and a dummy argument array for the function is not included in the variable.
Table 5.2-3 Checks on the Number of Data on the Left- and Right-Hand Sides of a Group Assignment Statement
Variables designated on the
left-hand side Variables designated on theright-hand side Check details
Local variable only Function block data only Error caused if there are more data on theright-hand side than the left-hand side. Function block data only Local variable only Error caused if there are more data on theleft-hand side than the right-hand side. Function block data only Function block data only Data on the left-hand side compared with da-
ta on the right-hand side that have less num- ber of data.
Local variable only Local variable only
Both function block data and local variable on either side or
both sides. Error caused if numbers of data different onboth sides.
<5.2 Group Assignment Statement>
5-12
A compiler error occurs when the dummy argument array for the function is not included in the variable. When a dummy argument array is included, no error is detected during compila- tion but a run-time error occurs. When a run-time error occurs, the values of the elements in the left hand side variable and the error array do not change and remain as they were before the group assign statement was executed.
When the number of elements in the error array is greater than the number of data to be pro- cessed, 0 or an error code is set in the array element of the number of data that appears at the start of the error array. If there is no corresponding data, the values of that error array ele- ments do not change.
An error occurs if the number of elements in the error array is smaller than the number of data to be processed.
n
Describing a Group Assignment Statement
An example of describing a group assignment statement is given below.
l
Accessing Data in the Same FCS
Suppose that tag names TAG0100A, TAG0100B exist as function blocks respectively.
In the example given below, because TAG0100A and TAG0100B exist in the same FCS, data setting in the order, TAG0100A.MODE, TAG0100A.SV, TAG0100B.MODE, TAG0100B.SV is guaranteed.
block PID TAG0100A,TAG0100B !FCS1 ...
[TAG0100A.MODE.SV,TAG0100B.MODE.SV = "AUT",10.0, \ "AUT",10.0]
...
l
Accessing Data in Another FCS
Suppose that tag names TAG0100A, TAG0100B and tag names TAG0200A, TAG0200B exist as function blocks respectively in FCS1 and FCS2.
In the example given below, setting of data from left to right in each FCS respectively, is guar- anteed as follows: for data in FCS1, TAG0100A.MODE, TAG0100A.SV, TAG0100B.MODE, TAG0100B.SV; for data in FCS2, TAG0200A.MODE, TAG0200A.SV, TAG0200B.MODE, TAG0200B.SV.
block PID TAG0100A,TAG0100B !FCS1 block PID TAG0200A,TAG0200B !FCS2 ...
IMPORTANT
The variable on the left-hand side of a group assignment statement cannot be used on the right-hand side or as the array subscript in the same statement. This is because it is confus- ing whether the value before or after the assignment to be used.
l
Accessing a Local Generic Name
In the program given below, it cannot be confirmed whether GEN001[3] or GEN001[5] in the local generic name array will be accessed.
... integer i
genname PID GEN001[10],GNAM001 ...
! incorrect program i=3
[i,GEN001[i].MODE,GNAM001.SV = 5,"AUT",100.0] ...
To confirm whether GEN001[3] or GEN001[5] in the local generic name array is accessed, place the substitute for the variable used in the subscript outside and describe as follows:
... integer i
genname PID GEN001[10],GNAM001 ...
! correct program i=5
[GEN001[i].MODE,GNAM001.SV = "AUT",100.0] ...
l
When the Set Value Becomes Undefined
In the following program, whether 5 or 10 is set in TAG001.SV is undefined:
... integer i
block PID TAG001 ...
! incorrect program i=5
[i,TAG001.SV = 10,i] ...
To set 10 in TAG001.SV, describe as follows.
... integer i
<5.2 Group Assignment Statement>
5-14
block PID TAG001 ... ! correct program i=5 [i,TAG001.SV = 10,10] ...
l
Reading the Block Mode and PV Value of the Function Block
In the example given below, block modes are read into local variables s1 and s2, and the PV values are read into local variables d1 and d2.
block PID TAG001,TAG002 char*16 s1,s2
double d1,d2 ...
[s1,d1,s2,d2 = TAG001.MODE.PV,TAG002.MODE.PV] ...
l
Designating Multiple Data Item Names for an Array
When designating multiple data item names for an array, the designation order is array ele- ment, then data item name.
genname PID TAG[3] ...
assign "TAG001" to TAG[1] assign "TAG002" to TAG[2] assign "TAG003" to TAG[3] ...
[TAG[*].MODE.SV = "AUT","AUT","AUT",10.0,10.0,10.0] ...
Data item names are stored in TAG[*].MODE.SV in the order, TAG[1].MODE, TAG[2].MODE, TAG[3].MODE, TAG[1].SV, TAG[2].SV, TAG[3].SV .