Arguments
The value returned by some functions is determined by the arguments specified in the function-identifier when the functions are evaluated. Some functions require no arguments; others require a fixed number of arguments, and still others accept a variable number of arguments.
An argument must be one of the following items:
- A data item identifier
- An arithmetic expression
- A function-identifier
- A literal other than a figurative constant
- A special-register
See Function definitions for function-specific argument specifications.
The types of arguments are:
- Alphabetic
- An elementary data item of the class alphabetic or an alphanumeric literal containing only alphabetic characters. The content of the argument is used to determine the value of the function. The length of the argument can be used to determine the value of the function.
- Alphanumeric
- A data item of the class alphabetic or alphanumeric or an alphanumeric literal. The content of the argument is used to determine the value of the function. The length of the argument can be used to determine the value of the function.
- DBCS
- An elementary data item of class DBCS or a DBCS literal. The content of the argument is used to determine the value of the function. The length of the argument can be used to determine the value of the function. (A DBCS data item or literal can be used as an argument only for the NATIONAL-OF function.)
- National
- A data item of class national (category national, national-edited, or numeric-edited). The content of the argument is used to determine the value of the function. The length of the argument can be used to determine the value of the function.
- UTF-8
- A data item of class UTF-8 (category UTF-8). The content of the argument is used to determine the value of the function. The length of the argument can be used to determine the value of the function.
- Integer
- An arithmetic expression that always results in an integer value. The value of the expression, including its sign, is used to determine the value of the function.
- Numeric
- An arithmetic expression. The expression can include numeric literals and data items of categories numeric, internal floating-point, and external floating-point. The numeric data items can have any usage permitted for the category of the data item (including NATIONAL). The value of the expression, including its sign, is used to determine the value of the function.
- Keyword
- A keyword shall be specified in accordance with the intrinsic function definition. The TRIM intrinsic function is an example of an intrinsic function with a keyword argument. The keywords LEADING and TRAILING may be specified as the second and optional argument of TRIM.
Some functions place constraints on their arguments, such as the acceptable range of values. If the values assigned as arguments for a function do not comply with specified constraints, the returned value is undefined.
If a nested function is used as an argument, the evaluation of its arguments is not affected by the arguments in the outer function.
Only those arguments at the same function level interact with each other. This interaction occurs in two areas:
- The computation of an arithmetic expression that appears as a function argument is affected by other arguments for that function.
- The evaluation of the function takes into consideration the attributes of all of its arguments.
When a function is evaluated, its arguments are evaluated individually in the order specified in the list of arguments, from left to right. The argument being evaluated can be a function-identifier or an expression that includes function-identifiers.
If an arithmetic expression is specified as an argument and if the first operator in the expression is a unary plus or a unary minus, the expression must be immediately preceded by a left parenthesis.
Floating-point literals are allowed wherever a numeric argument is allowed and in arithmetic expressions used in functions that allow a numeric argument.
Internal floating-point items and external floating-point items (both display floating-point and national floating-point) can be used wherever a numeric argument is allowed and in arithmetic expressions as arguments to a function that allows a numeric argument.
Floating-point items and floating-point literals cannot be used where an integer argument is required or where an argument of class alphanumeric or national is required (such as in the LOWER-CASE, REVERSE, UPPER-CASE, NUMVAL, and NUMVAL-C functions).
Where a function allows an alphanumeric, a national, or a UTF-8 argument to be specified, an alphanumeric group, a national or a UTF-8 group, respectively, can also be specified. However, an unbounded group cannot be specified as a function argument, except when it is used in the LENGTH intrinsic function.