DCLSRPARM
Estimated reading time: 7 minutes
Defines the parameters that will be received by BEGSR, BEGPROP, BEGPROC, BEGFUNC or BEGCONSTRUCTOR. Parameters can be passed by value or by reference .
DCLSRPARM
Name (<u>*NONE</u> | Variable name)
Type (*BINARY | *BOOLEAN | *BYTE | *CHAR | *DATE | *DECIMAL | *FLOAT | *FLOAT4
| *FLOAT8 | *DECIMAL | *FLOAT4 | *FLOAT8 | *IND | *INTEGER | *INTEGER2
| *INTEGER4 | *INTEGER8 | *OBJECT |*ONECHAR | *PACKED | *STRING | *TIME | *TIMESTAMP
| *ZONED | Form type, Field, Array, Array Element, Table name, String Literal,
Library.Object)
Len (Length Integer, [Decimal Integer])
By (<u>*VALUE</u> | *REFERENCE)
TimFmt (<u>*PGMDFT</u> | *DMY | *EUR | *HMS | *ISO | *JIS | *JUL | *MDY | *USA | *YMD)
Rank (IntegerLiteral)
Attributes (Attribute 1, Attribute 2, ...)
Like (Function name)
Options (*OMIT | *NOPASS)
[Support for Procedure Parameters]
Parameters
Name
Optional when used to declare parameters for a DCLPROTOTYPE, otherwise Required. Name can contain either:
- *NONE (default). If a specified name is not defined, this default prevents a warning if the parameter is not used.
- The name of the variable already defined.
-
A string literal, which defines an OBJECT variable of a particular type. The string literal must represent:NONE (default). If a specified name is not defined, this default prevents a warning if the parameter is not used. The name of the variable already defined. A string literal, which defines an *OBJECT variable of a particular type. The string literal must represent:
<ul type="square" style="LIST-STYLE-TYPE: square">
- a valid program id registered on your system at compile time.
- a valid class id registered on your system at compile time.
- A valid interface name registered on your system at compile time.
Type
Optional. Type can be any of the “” Types (CHAR, *BINARY, etc.) or it can be the name of a field already defined in the program.
- Type cannot be a named constant or a literal. In this case, the field will be defined based on the attributes of another field.
- If Type is an array, array element, or a table name, the attributes of an element of the array or table are used to define the field.
-
If Type is *BOOLEAN, you can use the *TRUE or *ON and *FALSE or *OFF special values to indicate True or False.
- If a Type parameter is not given, the Len parameter is required. In this case, *CHAR is assumed if there is one integer, and *ZONED is assumed if there are two integers.
- See Encore RPG Assemblies for more information.
Len
Optional. Len specifies the length of the variable. If Len is specified without a Type parameter, *CHAR is assumed if there is one integer, and *ZONED is assumed if there are two integers.
By
Optional. By specifies whether the parameter will be passed to the routine by value or by reference .
- *Value (default) - passes the parameter data to the subroutine. If the subroutine modifies the data of a *value SRPARM, the original parm data is unaffected.
- *Reference - a referenced parm is one where the pointer memory location of the variable is passed to the subroutine. Any change made to the parameter data will change the data of the parameter variable in the parameter. When passing parameters by reference, you must use the ***** ByRef operator.
TimFmt
Optional. TimFmt specifies the format for time, date, and timestamp variables. If the TimFmt parameter is not specified, the format specified by the program is assumed.
Rank
Optional. Rank declares an n-dimensional array of indefinite elements. The value given for Rank defines the number of dimensions for the array.
Attributes
Optional. Attributes allows you to provide one or more attributes on the object being defined by the command. To specify more than one attribute, simply separate them with commas.
Attributes use required, and optional arguments. The required parameters are provided in positional fashion. Positional arguments are arguments that are specified in the order they are declared for the constructor of an attribute. For example, the following code calls the Developer constructor of an attribute with two values:
BegClass MyClass Attributes(Developer("Joe Cool", 17))
You can also use named arguments, which are optional, to directly set the value of properties and fields of the attributes. You specify a named argument by appending “:=” to the name of the argument, followed by the value being specified. Unlike positional arguments, named arguments can be specified in any order. For example, the following code sets the value * True for the Reviewed
property of the Developer
Attribute, and False for the Keep
field:
BegClass MyClass Attributes(Developer("Joe Cool", 17, Reviewed:=*True)
Note You must use positional arguments for arguments that are used with the attribute’s constructor. Named arguments can only be used to set the values of fields and properties of attribute classes.
Like
Optional. Like must be the name of a property already defined in the class. Type cannot be a named constant or a literal. In this case, the property will be defined based on the attributes of another property. If Type is an array, array element, or a table name, the attributes of an element of the array or table are used to define the field. You can use Len parameter to make the declared field longer or shorter than the Like parameter entry.
A plus sign (+) preceding the number indicates a length increase; a minus sign (-) indicates a length decrease. You cannot change the number of decimal positions for the property being defined. The length entry is allowed only for property definitions requiring a length.
Options [Support for Procedure Parameters]
Optional. Options is available only when using BEGPROC procedures. It may contain * OMIT or * NOPASS , as described below. See BEGPROC for an example in using the Options keyword.
- OMIT - specifies that the parameter *may either contain a valid value according to its type, or that the special value *OMIT may be passed instead. Use %OMITTED to know whether this parameter contains a valid value.
- NOPASS - specfies that the parameter *may not be passed in the parameter list. Once a parameter declares this option, all the parameters that follow MUST also declare it. Use %PARMS to know how many parameters were actually passed at a CALLB site.
Remarks