Difference between revisions of "DCL — Declare CL Variable"
DaveLClarkI (talk | contribs) (Created page with "Category:CLP == Summary == The {{AN}} command is used in CLP programs to declare the definition for a program variable. Such variables may either be to receive parameter ...") |
DaveLClarkI (talk | contribs) |
||
Line 1: | Line 1: | ||
[[Category:CLP]] | [[Category:CLP]] | ||
== Summary == | == Summary == | ||
− | The | + | The DCL command is used in CLP programs to declare the definition for a program variable. Such variables may either be to receive parameter values passed to the CLP program, for work variables that are only used within the CLP program, or for variables that are to be passed to other programs called by the CLP program. |
== Command definition == | == Command definition == |
Revision as of 21:06, 6 April 2016
Contents
Summary
The DCL command is used in CLP programs to declare the definition for a program variable. Such variables may either be to receive parameter values passed to the CLP program, for work variables that are only used within the CLP program, or for variables that are to be passed to other programs called by the CLP program.
Command definition
DCL VAR() TYPE() STG() LEN() VALUE() + BASPTR() DEFVAR() ADDRESS()
Note: Some of these parameters were added at subsequent release levels and the values for these parameters also changed at subsequent release levels. Some parameters are mutually exclusive depending on which parameters and their values are specified.
Parameters
CL variable name (VAR)
This is the name of the CL variable, may be up to 10 characters in length, and must be prefixed by an ampersand (&).
Type (TYPE)
This is the data type for the CL variable — as follows.
Keyword | Data type |
---|---|
*DEC | A variable with a packed decimal value. |
*CHAR | A variable with a character string value. |
*LGL | A variable with a Boolean logical value of '0' (fales) or '1' (true). |
*INT | A variable with a signed binary value. |
*UINT | A variable with an unsigned binary value. |
*PTR | A variable with an address pointer value. |
Storage (STG)
This is the storage type for the variable — as follows.
Keyword | Storage type |
---|---|
*AUTO | The variable's storage is automatically allocated. |
*BASED | The variable's storage is based on the storage address of another variable. The BASPTR parameter must be specified for this variable. |
*DEFINED | The variable's storage is provided by a variable that has already been defined. The DEFVAR parameter must be specified for this variable. |
Length of variable (LEN)
This is the length for the variable. The value for this parameter is either the number of characters (up to 32,767), bytes, or the total number of digits (left and right of the implied decimal point, up to 15) that can be contained in the variable. If an integer variable, the number of bytes must be 2, 4, or 8 (ILE, only). If a decimal variable, a second value may be specified that is the number of digits (up to 9) to the right of the implied decimal point (the default is zero if not specified).
Note: Pointer variables have a default fixed length of 16 bytes and this parameter cannot be specified.
Initial value (VALUE)
This is an optional initial value for the variable. By default, character variables are blank, numeric variables are zero, logical variables are '0', and pointer variables are *NULL. Incoming parameter variables cannot have an initial value specified because they receive their value from the calling program.
Basing pointer variable (BASPTR)
The value for this parameter must be the CL variable name of a pointer variable.
Defined on (DEFVAR)
The first value for this variable is the name of the defined variable over which this variable will be defined — based on the second value for this parameter. The second value is this variable's beginning position in the defined variable starting from the beginning of that variable.
Address (ADDRESS)
This is an optional initial address for a pointer variable — which may be specified as *NULL. The value for this parameter may be the name of another CL variable and an offset from that variable (where zero (0) indicates the beginning of that CL variable).