what_return_field_from_group_.htm
| Navigation: Language Reference > 13 - Built-in Functions >====== WHAT (return field from group) ====== | ![]() ![]() |
WHAT( group, number [,dimension] )
| WHAT | Returns a specified field from a group structure. |
| group | The label of a GROUP, RECORD, CLASS, or QUEUE declaration. |
| number | An integer expression specifying the ordinal position of a field in the group. |
| dimension | An optional dimension element number, if applicable. |
The WHAT statement returns the number specified field from a group structure. Generally, this would be assigned to an ANY variable. If the number specified field is a dimensioned field, then WHAT returns a reference to the dimension element of the number field.
If the field with an ordinal position equal to the passed second parameter is defined as an ANY type or has the DIM attribute, the returned value can only be used in “reference equality” ( &= ) operations. Any attempt to access the field will cause a run-time error.
Return Data Type: ANY
Example:
MyGroup GROUP
F1 LONG(3) !Field number 1
F2 SHORT !Field number 2
F3 STRING(30) !Field number 3
InGroup GROUP !Field number 4
F1 LONG !Field number 5
F2 SHORT(2) !Field number 6
F3 STRING(30),DIM(2) !Field number 7
F4 LONG,DIM(3,3) !Field number 8
F5 ANY
END
END
CurrentField ANY
CODE
CurrentField &= WHAT(MyGroup,1) !Returns contents of MyGroup.F1 (3)
CurrentField &= WHAT(MyGroup,6) !Returns contents of MyGroup.Ingroup.F2 (2)
CurrentField &= WHAT(MyGroup,7) !Returns contents of MyGroup.Ingroup.F3[1]
IF CurrentField &= RefVar !LEGAL
CurrentField = 2 !INVALID – posts a runtime error
END
CurrentField &= WHAT(MyGroup,8,3) !Returns contents of MyGroup.Ingroup.F4[1,3]
CurrentField &= WHAT(MyGroup,8,5) !Returns contents of MyGroup.Ingroup.F4[2,2]
!For String Comparison, the returned field must be moved into a work field:
CurrentField &= WHAT(MyGroup,8,7) !Returns contents of MyGroup.Ingroup.F4[3,1]
IF CurrentField = 'xyz'
!do something
END
See Also:
what_return_field_from_group_.htm.txt · Last modified: by carlbarnes




