Variable update action with a field variable
Using a Variable update action to update a field variable is a convenient way of reading the contents of a 3270 or 5250 field in the host terminal and storing the field's contents as a string into a variable.
A field variable is a type of string variable. A field variable is defined in the <vars> element of the macro script but does not take an initial value. The following contains an example of a field variable.
<vars>
<create name=$intUpdate$" type="integer" value="3"/>
<create name="$strData$" type="string" value="'hello'"/>
<create name="$fieldVar$" type="field" />
</vars>
A field variable contains a string, just as a string variable does, and you can use a field variable in any context in which a string variable is valid. However, a field variable differs from a string variable in the way in which a string is stored into the field variable. The string that a field variable contains is always a string that the macro runtime has read from a 3270 or 5250 field in the current host terminal.
- The name of the field variable, such as $fldTmp$.
- A location string, such as '5,11'. (A location string is a string containing two integers separated by a comma that represent a row and column location on the host terminal.)
- Recognizes that the variable is a field variable.
- Looks at the location string that is to be used to update the field variable.
- Finds in the current host terminal the row and column location specified by the location string.
- Finds in the current host terminal the 3270 or 5250 field in which the row and column location occurs.
- Reads the entire contents of the 3270 or 5250 field, including any leading and trailing blanks.
- Stores the entire contents of the field as a string into the field variable.
'The field\'s contents are'+ $fldPrintOption$
- It begins at row 5, column 8
- It ends at row 5, column 32
- It contains the string 'Print VTOC information'
- In the variable name field you type the name of a field variable that you have just created, $fldData$.
- In the value field you type a location string, '5,11'. Notice that you have to specify only one row and column location, and that it can be any row and column location that lies within the field.