Domain: Variable access (variable name)
The FIRST-VARIABLE-NAME( ) function can be used to analyze the format of complex variables, primarily in combination with the NEXT-VARIABLE-NAME( ) function. FIRST-VARIABLE-NAME( ) can be applied to all aggregates and lists. FIRST-VARIABLE-
NAME( ) begins with the specified variable or variable element name and then supplies the name of the first variable. If there is no lower level, FIRST-VARIABLE-NAME( ) returns *END.
Format
FIRST-VARIABLE-NAME( ) FIRST-VAR-NAME( ) |
VARIABLE-NAME = string_expression |
Result type
STRING (<composed-name 1..255> or ’*END’)
Input parameters
VARIABLE-NAME = string_expression
Designates a complex variable or a variable element.
If the complex variable is a list, the name of the first list element (list#1) is supplied.
If the variable element is a list element, *END or the name of the appropriate element is output. The variable name must be enclosed in apostrophes if it is specified directly, i.e. as a literal (see the example on the next page).
Result
elementname, if “string_expression” designates a complex variable.
*END
“string_expression” designates a variable element on the lowest level which is itself no longer a complex variable; this means that there is no lower level.
Error message
SDP1101 SYNTAX ERROR IN VARIABLE NAME
Example
The variable FSTAT is declared as an array with dynamic structures as its elements.
/DECLARE-VARIABLE FSTAT(TYPE=*STRUCTURE(*DYNAMIC)),MULTIPLE-ELEMENTS=*ARRAY
The elements of these dynamic structures are initialized as follows:
/FSTAT#1.F-NAME = 'FILE.A' /FSTAT#1.F-SIZE = 0000003 /FSTAT#2.F-NAME = 'FILE.B' /FSTAT#2.F-SIZE = 000006
FIRST-VARIABLE-NAME can be used to analyze the variable:
/A = FIRST-VARIABLE-NAME('FSTAT') /SHOW-VARIABLE A A = FSTAT#1 /B = FIRST-VARIABLE-NAME(A) /SHOW-VARIABLE B B = FSTAT#1.FNAME /C = FIRST-VARIABLE-NAME(B) /SHOW-VARIABLE C C = *END