“drivewait” Designation
6. Process Management ▼ Process Management
6.1 Accessing Common Block Data
Operations started from a unit recipe can access common blocks using built-in functions. This section explains the types of recipe common blocks and how to read or write common block data.
n
Types of Recipe Common Blocks
The recipe common blocks include system-fixed common blocks and user-defined common blocks. The system-fixed common blocks are further classified into two types: SYSRCM and SYSPCMnn.
• SYSRCM
There is one SYSRCM for Each recipe.
• SYSPCMnn
There is one SYSPCMnn for each unit recipe. nn indicates the unit recupe number. If the number is a single-digit value, add “0” as in “SYSPCM01” and “SYSPCM02.”
In operations started from a unit recipe, all of the common block data for that recipe can be read or written using built-in functions.
n
Reading Common Block Data
Use the built-in functions lcmread(), dcmread() and ccmread() to read common block data.
• Simple variable
lcmread (<common block name>, <data item name>) dcmread (<common block name>, <data item name>) ccmread (<common block name>, <data item name>) • One-dimensional array element
lcmread (<common block name>, <data item name>, <1-dim. subscript>) dcmread (<common block name>, <data item name>, <1-dim. subscript>) ccmread (<common block name>, <data item name>, <1-dim. subscript>) • Two-dimensional array element
lcmread (<common block name>, <data item name>, <1-dim. subscript>, <2-dim. subscript>)
dcmread (<common block name>, <data item name>, <1-dim. subscript>, <2-dim. subscript>)
ccmread (<common block name>, <data item name>, <1-dim. subscript>, <2-dim. subscript>)
<common block name>
Specify the common block name using a character-string variable or character-string constant. Use uppercase letters
for the common block name.
<data item name> Specify the data item name using a character-string variable or character-string constant. Use uppercase letters for the
data item name.
<1-dim., 2-dim. subscript>
Specify the array subscript(s) using a variable or constant. An expression comprising two or more terms such as “i + 1”
cannot be specified.
Figure 6.1-1 The format of the built-in function "lcmread()", "dcmread()" and "ccmread()"
lcmread() is a built-in function of long type, dcmread() of double type and ccmread() of char*n type.
<6.1 Accessing Common Block Data >
6-2
To read numeric data from a common block, use lcmread() or dcmread(). If the type of the common block data is different from that of the built-in function, the common block data is converted to the type of the built-in function.
It is recommended that lcmread() be used when reading integer-type and long-type common block data, while dcmread() be used when reading float-type and long-type common block da- ta.
Use ccmread() when reading character-string type common block data.
Table 6.1-1 Reading Common Block Data
Function name Type Return value at normal execution
lcmread long Common block data other than of long type are converted to long type. dcmread double Common block data other than of double type are converted to doubletype. ccmread char*n A character string of the string length of the common block data.
• If common block data cannot be read because the common block or data item not exist or because the array subscript range is exceeded, the execution of that line is stopped. For example, if an error occurs in the following lcmread assignment statement for any of these reasons, assignment to the left-hand side is not performed and the “ldata” value will not change.
... long data ...
ldata = lcmread ("SYSRCM", "MISTAKE") ! data item "MISTAKE" does not exist ...
• If the common block data is of float or double type in lcmread(), long-type conversion may cause the data to overflow. In this case, the return value becomes the maximum value of the same sign.
n
Writing Common Block Data
Use the built-in function cmwrite() to write common block data.
• Simple variable
cmwrite (<common block name>, <data item name>, <data>) • One-dimensional array element
cmwrite (<common block name>, <data item name>, <1-dim. subscript>, <data>) • Two-dimensional array element
cmwrite (<common block name>, <data item name>, <1-dim. subscript>, <2-dim. subscript>,<data>)
<common block name>
Specify the common block name using a character-string variable or character-string constant. Use uppercase letters
for the common block name.
<data item name> Specify the data item name using a character-string variable or character-string constant. Use uppercase letters for the
data item name.
<1-dim., 2-dim. subscript>
Specify the array subscript(s) using a variable or constant. <data> Specify the data to be set as common block data using
a variable or constant.
Figure 6.1-2 The format of the built-in function "cmwrite()"
cmwrite() sets <data> as common block data. If the type of the <data> specified as an argu- ment of the built-in function is different from that of the common block data, <data> is conver- ted to the type of the common block data. However, if <data> is of numeric type and the com- mon block data is of character-string type, or if <data> is of character-string type and the com- mon block data is of numeric type, a run-time error occurs and data will not be set.
Table 6.1-2 Setting Common Block Data
Function name Type Return value at normalexecution Return value at error
cmwrite integer 0 -1
<6.1 Accessing Common Block Data >