Domain: Variable access (variable name)
The NEXT-VARIABLE-NAME( ) function can be used to analyze the layout of complex variables, primarily in connection with the FIRST-VARIABLE-NAME( ) function.
The NEXT-VARIABLE-NAME( ) function supplies the name of the next variable element on the same level. If there are no more variable elements on this level, NEXT-VARIABLE-NAME( ) returns *END.
Format
NEXT-VARIABLE-NAME( ) NEXT-VAR-NAME( ) |
VARIABLE-NAME = string_expression |
Result type
STRING
Input parameters
VARIABLE-NAME = string_expression
Designates a variable.
If VARIABLE-NAME designates a list, *END or the appropriate element name is output.
If VARIABLE-NAME designates a list element (list#i), the name of the next element is output (list#i+1), as long as one exists. If the list element list#i+1 does not exist, *END is output. The variable name must be enclosed in apostrophes if it is specified directly, i.e. as a literal (see the following example and the examples in the description of IS-DECLARED( )).
Result
Name of the element following “string_expression” in the complex variable on the same level.
*END
“string_expression” was the last element on the level.
Error message
SDP1101 SYNTAX ERROR IN VARIABLE NAME
Example 1
A compound variable AR contains the following elements.
AR#1 AR#2 AR#3 /A = NEXT-VARIABLE-NAME(VARIABLE-NAME = 'AR#1') /SHOW-VARIABLE A A = AR#2 /A = NEXT-VARIABLE-NAME(VARIABLE-NAME = 'AR#3') /SHOW-VARIABLE A A = *END
If NEXT-VARIABLE-NAME( ) is used with AR#1, AR#2 will be supplied (the name of the element following AR#1).
AR#3 is the last element of the array; therefore, NEXT-VARIABLE-NAME( ) supplies *END.
Example 2
A compound variable ARR contains the following elements:
ARR#1 ARR#22 ARR#30 /A = NEXT-VAR-NAME('ARR#1') /SHOW-VARIABLE A A = ARR#22