General syntax of DEFINE DATA PARAMETER
:
PARAMETER |
USING
parameter-data-area |
|||||
parameter-data-definition |
This document covers the following topics:
For an explanation of the symbols used in the syntax diagram, see Syntax Symbols.
The DEFINE DATA PARAMETER
statement is used to define the
data elements that are to be used as incoming parameters in a Natural
subprogram, external subroutine or helproutine. These parameters can be defined within the
statement itself (see Parameter Data
Definition below); or they can be defined outside the
program in a parameter data area (PDA),
with the statement referencing that data area.
Parameter data elements must not be assigned initial or constant values, and they must not have edit mask (EM), header (HD) or print mode (PM) definitions (see also EM, HD, PM Parameters for Field/Variable).
The parameter data area and the objects which reference it must be contained in the same library (or in a steplib).
USING parameter-data-area | The name of the parameter-data-area that contains data elements which are used as parameters in a subprogram, external subroutine or dialog. |
---|---|
parameter-data-definition | Instead of defining a parameter data area, parameter data can also be defined directly within a program or routine; see Parameter Data Definition below. |
END-DEFINE | The Natural reserved word END-DEFINE must be used
to end the DEFINE DATA statement.
|
For direct parameter data definition, the following syntax applies:
level | group-name [(array-definition)] | ||||||||||||||
redefinition | |||||||||||||||
(format-length[/array-definition]) | |||||||||||||||
variable-name | [BY VALUE [RESULT ]]
[OPTIONAL ]
|
||||||||||||||
[(array-definition)] | DYNAMIC |
||||||||||||||
parameter-handle-definition [BY VALUE [RESULT ]]
[OPTIONAL ]
|
Syntax Element Description:
level |
Level number is a 1- or 2-digit number in the range from 01 to 99 (the leading zero is optional) used in conjunction with field grouping. Fields assigned a level number of 02 or greater are considered to be a part of the immediately preceding group which has been assigned a lower level number. The definition of a group enables reference to a series of fields
(may also be only 1 field) by using the group name. With certain statements
( A group may consist of other groups. When assigning the level numbers for a group, no level numbers may be skipped. |
|
---|---|---|
group-name | The name of a group. The name must
adhere to the rules for defining a Natural variable name. See also the
following sections:
|
|
array-definition | With an array-definition, you define the lower and upper bounds of dimensions in an array-definition. See Array Dimension Definition and Variable Arrays in a Parameter Data Area. | |
redefinition |
A redefinition may be used to redefine a group or a single field/variable (that is a scalar or an array). See Redefinition. Note: |
|
variable-name | The name to be assigned to the variable. Rules for Natural variable names apply. For information on naming conventions for user-defined variables, see Naming Conventions for User-Defined Variables in the Using Natural documentation. | |
format-length | The format and length of the field. For information on format/length definition of user-defined variables, see Format and Length of User-Defined Variables in the Programming Guide. | |
A, U or B | Data type: alphanumeric (A), Unicode (U) or binary (B) for dynamic variable. | |
DYNAMIC | A parameter may be defined as
DYNAMIC . For more information on processing dynamic variables, see
Introduction to Dynamic
Variables and Fields.
|
|
Call Mode:
Depending on whether call-by-reference, call-by-value or
call-by-value-result is used, the appropriate transfer mechanism is applicable.
For further information, see the |
||
(without BY VALUE) |
Call-by-reference:
Call-by-reference is active by default when you omit the |
|
BY VALUE |
Call-by-value:
When you specify
|
|
Example of BY VALUE: | ||
* Program DEFINE DATA LOCAL 1 #FIELDA (P5) ... END-DEFINE ... CALLNAT 'SUBR01' #FIELDA ... |
* Subroutine SUBR01 DEFINE DATA PARAMETER 1 #FIELDB (P9) BY VALUE END-DEFINE ... |
|
BY VALUE RESULT |
Call-by-value-result:
While With |
|
OPTIONAL |
For a parameter defined without For a parameter defined with In the invoking object, the notation
With the |
|
parameter-handle-definition | See the section Parameter Handle Definition below. |
Syntax of parameter-handle-definition:
handle-name [(array-definition)]
HANDLE OF
OBJECT |
Syntax Element Description:
handle-name | The name to be assigned to the handle; the naming conventions for user-defined variables apply; see Naming Conventions for User-Defined Variables in the Using Natural documentation.. |
---|---|
HANDLE OF OBJECT | Is used in conjunction with NaturalX as described in the section NaturalX of the Programming Guide. |
array-definition | With an array-definition, you define the lower and upper bounds of dimensions in an array-definition. See Array Dimension Definition. |