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:
When the macro runtime performs the Variable update action, the macro runtime:
  1. Recognizes that the variable is a field variable.
  2. Looks at the location string that is to be used to update the field variable.
  3. Finds in the current session window the row and column location specified by the location string.
  4. Finds in the current session window the 3270 or 5250 field in which the row and column location occurs.
  5. Reads the entire contents of the 3270 or 5250 field, including any leading and trailing blanks.
  6. 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: You set up a Variable update action with the following values: When the macro runtime performs this Variable update action, the macro runtime reads the entire contents of the field and stores the contents as a string into $fldData$. The field variable $fldData$ now contains the string 'Print VTOC information'.