DFT (Default enumeration constant)
DFT (Default enumeration constant)
The DFT keyword is used to identify the default constant in a
typed enumeration. See Typed Enumerations.
When a field is defined like the typed enumeration, the default constant
is the value used for the CLEAR
operation for the field,
and it is used to initialize the field if the INZ
keyword is not specified.
If this keyword is not specified for one of the constants in the enumeration, the first constant listed in the enumeration is the default constant.
In the following example:
- The PROJECT_DIR
enumeration is defined with data type
VARCHAR(25). - The
DFTkeyword as identifies the current constant as the default. - Field myProjectDir is defined like the
PROJECT_DIR enumeration. The
INZkeyword is not specified, so it is initialized to the value of the default current constant,'./'. - Field myProjectDir is also defined like the
PROJECT_DIR enumeration.
The
INZkeyword is specified, so it is initialized to the specified production constant,'/home/myproject/prod/'. - The
CLEARoperation clears both fields to the default constant of the enumeration,'./'.
CTL-OPT CCSID(*EXACT);
DCL-ENUM PROJECT_DIR VARCHAR(25) QUALIFIED; // 1
development '/home/myproject/dev/';
production '/home/myproject/prod/';
current './' DFT; // 2
END-ENUM;
DCL-S myProjectDir LIKE(PROJECT_DIR); // 3
DCL-S productionDir LIKE(PROJECT_DIR) INZ(PROJECT_DIR.production); // 4
CLEAR myProjectDir; // 5
CLEAR productionDir; // 5
For more examples of the DFT keyword,
see Free-Form Enumeration Definition.