Introduction
Using the SET instruction with EXPRESS as the source can save code and programming time by combining multiple calculations into a single line. “Standard” or “Expanded” language level must be selected under SETUP / TEACHING COND. to use the EXPRESS option. This document provides an overview of using the EXPRESS tag.
Overview
Some applications require multiple calculations for a single variable. To reduce the length of a program these calculations can be combined into single line SET instruction. The SET instruction (in the ARITH section of INFORM LIST) has an option for the SOURCE to be an expression (EXPRESS) at bottom of the drop-down menu. The destination must be Byte (B / B [ ] / LB / LB [ ] ), Integer (I / I [ ] / LI / LI [ ] ), Double Integer (D / D [ ] / LD / LD [ ] ), or Real (R / R [ ] / LR / LR [ ] ), for the EXPRESS option. The SOURCE drop-down menu options vary depending on the DESTINATION selected and whether local variables have been enabled. EXPRESS can only be enabled from the Detail Edit screen of the SET instruction.
Selecting EXPRESS will open detail edit of expression.
Moving your cursor under the first parenthesis allows user to add parentheses to an expression. Up to 3 can be added and negative is permitted. Each press of SELECT key will advance the parentheses options. The order is as follows ( (( ((( -( -(( -((( resetting to no parentheses.
Cursor right once to select negative for data line.
Cursor right again will allow for editing of data
The cursor down arrow under OPERATOR will allow for changing of data
Pressing SELECT will show drop-down menu options for data type selection. Menu options will vary with enabling of local variables.
Moving the cursor to right of the down arrow will register ending parentheses. Each press of the SELECT key will advance parentheses options. The order is as follows ( (( ((( -( -(( -((( resetting to no parentheses.
The far-right cursor location sets register for next line if required. Do not make this selection if you are at the end of your expression.
Pressing SELECT will show a drop-down menu for next operation of the expression. If not required use the cancel key. An added Data line cannot be removed. The line will need to be deleted and re-entered if data lines need removed.
The detail edit screen data will appear different after an expression has been registered.
Expression Example
SET B000 (B001 + B002) / D003 - (I004 + D005) * - B006
B000 is DESTINATION.
(B001 + B002) / D003 - (I004 + D005) * - B006 is the SOURCE expression
Up to 15 data entries are available with expression. Do not select + - * / after the last data of your expression. Data lines cannot be removed once added. The line will need to be deleted and re-entered if data lines need removed.
Beyond usage of variable and constant values, IO groups can also be used in expressions. The IG# (input group), IGU# (user input group), OG# (output group), and OGU# (user output group) transfer on status bits for variable calculation.
Use caution with expressions. It can be easy to exceed allowable values of the destination variable when using an expression. Know variables limitations and potential values of expression when using expressions. Alarm 4446 OVER VARIABLE LIMIT will occur and stop job if value of expression exceeds limit of variable.
After an expression is defined, limited editing of the expression is possible within the job. With your cursor on the instruction side of the line press SELECT. The cursor will drop to lower Edit Buffer Line. Use left/right arrow keys to move the cursor for editing of the expression. This method does not allow user to change outside preregistered data type. The user can change within a data type (for example, from one double to another double, one byte to another byte, etc.) However, you cannot cross from one data type to another. If the user needs to change a data type, it must be done from the detail edit screen.
Destination data type change will result in deletion of expression previously written.
Comments
0 comments
Please sign in to leave a comment.