Domain: Variable access (variable attributes)
The VARIABLE-ATTRIBUTE( ) function supplies the value of the specified attribute for the specified variable. Attributes are the variable attributes defined with SDF-P command DECLARE-VARIABLE. Keywords for the request are normally the operand names of the command.
Detailed information on structures must be requested with ATTRIBUTE = *STRUCTURE-INFO (not ATTRIBUTE = *TYPE).
Format
VARIABLE-ATTRIBUTE( ) VAR-ATTR( ) |
VARIABLE-NAME = string_expression ,ATTRIBUTE = *TYPE / *CONTAINER / *CONTAINER-NAME / *CONTAINER-SCOPE / *MULTIPLE-ELEMENTS / *SCOPE / *STRUCTURE-INFO |
Result type
STRING
Input parameters
VARIABLE-NAME = string_expression
Designates a variable. The variable name must be enclosed in apostrophes if it is specified directly, i.e as a literal (see the following example and the last example in the description of IS-DECLARED( ) ).
ATTRIBUTE =
Designates a variable attribute.
ATTRIBUTE = *TYPE
Supplies the variable type.
If the variable designated by “string_expression” is a structure, only the value *STRUCTURE is supplied.
ATTRIBUTE = *CONTAINER
Supplies the type of the variable container.
ATTRIBUTE = *CONTAINER-NAME
Supplies the name of the variable container.
ATTRIBUTE = *CONTAINER-SCOPE
Supplies the scope of the variable container.
ATTRIBUTE = *MULTIPLE-ELEMENTS
Supplies the type of the complex variable.
ATTRIBUTE = *SCOPE
Supplies the scope of the variable.
ATTRIBUTE = *STRUCTURE-INFO
Supplies the attributes of the complex variable designated by “string_expression” and having the type “structure”. These attributes are defined with the operand TYPE = *STRUCTURE(DEFINITION = ...) in the DECLARE-VARIABLE command.
Result
Value of the attribute in the form of a string.
Input parameter | Result |
*TYPE | '*ANY' / '*BOOLEAN' / '*INTEGER' / '*STRING' '*STRUCTURE' |
*CONTAINER | '*STD' / '*VARIABLE' / '*JV' / 'composed-name' |
*CONTAINER-NAME | 'name' / “ If the variable does not have a container: |
*CONTAINER-SCOPE | '*INCLUDE' / '*PROCEDURE' / '*TASK' If the variable does not have a container: '*ARRAY' / '*LIST' '*NO' |
*MULTIPLE-ELEMENTS | |
*SCOPE | '*INCLUDE' / '*PROCEDURE' / '*TASK' Scope of the variable designated with |
*STRUCTURE-INFO | '*BY-SYSCMD' '*DYNAMIC' 'name' |
Error messages
SDP0424 NO CONTAINER ASSIGNED TO VARIABLE '(&00)' SDP0425 BUILTIN FUNCTION VAR-ATTRIBUTES: VARIABLE NOT A STRUCTURE SDP1007 NO VARIABLE DECLARED SDP1101 SYNTAX ERROR IN VARIABLE NAME
Example 1
/BEGIN-STRUCTURE PERSON ... /END-STRUCTURE /DECLARE-VARIABLE A (TYPE = *STRUCTURE(PERSON)) ... /B = VARIABLE-ATTRIBUTE(VARIABLE-NAME = 'A', ATTRIBUTE = *TYPE) /SHOW-VARIABLE B B = *STRUCTURE /B = VARIABLE-ATTRIBUTE(VARIABLE-NAME = 'A', ATTRIBUTE = *STRUCTURE-INFO) /SHOW-VARIABLE B B = PERSON
Example 2
/OPEN-VARIABLE-CONTAINER mycontainer,*LIB(mylibrary) /DECLARE-VARIABLE myvar, CONTAINER= mycontainer /A = VARIABLE-ATTRIBUTE('myvar',*CONTAINER) /SHOW-VARIABLE A A = MYCONTAINER /A = VARIABLE-ATTRIBUTE('myvar',*CONTAINER-NAME) /SHOW-VARIABLE A A = “null string”