Domain: Variable access/test functions
The IS-DECLARED( ) function checks whether the specified simple or complex variable has already been declared.
Format
IS-DECLARED( ) |
VARIABLE-NAME = string_expression ,SCOPE = *BY-HIERARCHY / *TASK / *CALLING-PROCEDURES |
Result type
BOOLEAN
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 example on the next page).
SCOPE =
Designates the scope in which the variable is searched for.
SCOPE = *BY-HIERARCHY
The INCLUDE scope is searched first, then the PROCEDURE scope and finally the task scope. Task variables are only visible if they have been imported.
SCOPE = *TASK
Only the task scope is searched.
SCOPE = *CALLING-PROCEDURES
Checks whether the specified variable has already been declared with
IMPORT-ALLOWED = *YES. The search for the variable proceeds from the calling procedure upwards to the dialog level (in a foreground procedure) or up to the first procedure (in a background procedure). If the variable found has been declared with IMPORT-ALLOWED = *NO, the search is resumed, provided that the entire scope has not already been searched.
If this check eventually finds a variable with the specified name which has been declared with IMPORT-ALLOWED = *YES, the value TRUE is returned. If no such variable is found, the value FALSE is returned.
Result
TRUE
The variable designated in the VARIABLE-NAME parameter has been declared in the specified scope (or has been declared with IMPORT-ALLOWED=*YES, as appropriate).
FALSE
The variable designated in the VARIABLE-NAME parameter has not been declared in the specified scope (or has not been declared with IMPORT-ALLOWED=*YES, as
appropriate).
Error messages
SDP0010 TYPE OF PARAMETER '(&00)' INVALID SDP1101 SYNTAX ERROR IN VARIABLE NAME
Example
The following variable “A” is declared and the procedure “proc2” called in procedure “proc1”:
/DECLARE-VARIABLE VARIABLE-NAME=A(TYPE=*INTEGER,INITIAL-VALUE=12),- /SCOPE=*PROCEDURE(IMPORT-ALLOWED=*YES) /CALL-PROCEDURE Proc2
Procedure “proc2” contains the following:
/B=IS-DECLARED(VARIABLE-NAME=‘A‘,SCOPE=*CALLING-PROCEDURES) /SHOW-VARIABLE VARIABLE-NAME=B
Output
B=TRUE