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 session window and storing the field's contents as a string into a variable.
A field variable is a type of string variable. 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 session window.
When you use the Variable update action to update a string variable,
you specify the following information in the Variable update window:
- 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 session window.)
When the macro runtime performs the Variable update action, the
macro runtime:
- 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 session window the row and column location specified by the location string.
- Finds in the current session window 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.
You can then use the field variable in any context in which a string
is valid. For example, you can concatenate the field variable with
another string, as in the following:
'The field\'s contents are'+ $fldPrintOption$
As an example, suppose that the session window contains a 3270
or 5250 field with the following characteristics:
- It begins at row 5, column 8.
- It ends at row 5, column 32.
- It contains the string 'Print VTOC information'.
- In the Name field of the Variable update window 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.