Syntax
function([[[parameter =] value], ...]) |
function
Name of the function.
parameter
Name of an input parameter; can be omitted.
value
Value of the input parameter.
Keyword or expression that corresponds to a data type that is valid in SDF-P (STRING, INTEGER, BOOLEAN; for information on expressions, see chapter “Expressions”).
A keyword must always begin with an asterisk (to distinguish keywords from variable names).
Examples
Keyword as parameter value:
DATE(FORMAT=*ISO)
Expression as parameter value:
/ADDRESS = 'hello' /U = UPPER-CASE(STRING=ADDRESS)
or:
/A = 3 /INT = INTEGER(190+A)
Functions can have several input parameters that must all comply with this syntax. In accordance with the rules for structured programming and to facilitate program maintenance, parameter names should be specified wherever possible, especially in function calls with several input parameters.
Keyword/positional parameters
In the case of functions with several input parameters, a distinction must be made between keyword parameters and positional parameters.
When keyword parameters are used, the parameter name is identified in the assignment as a keyword. The PARAMETER = VALUE assignments can then be in any order.
When positional parameters are used, the parameter name and equals sign are omitted from the assignment; only the parameter value is specified. The assignment is then identifiable by its position within the assignment sequence only.
If you do not specify parameter names in the function call, the order of input parameters must comply with the order given in the functional description in chapter “Predefinedfunctions” (Predefined functions ). If no parameter names are specified, SDF-P evaluates the parameter values in the function call in this exact order.
The rules for positional and keyword parameters in SDF-P functions correspond to the general rules for positional and keyword parameters in SDF commands. Important: positional parameters are only allowed before keyword parameters.
Example
In the syntax representation of the FILL function, the input parameters are listed in the following order: STRING, LENGTH, SIDE, FILL-BYTE. The value of the SIDE input parameter is specified by means of a keyword (*RIGHT or *LEFT); the values of the other input parameters are expressions that can be specified by means of variables or directly as a single character (for FILL-BYTE), a string (for STRING) or a number (for LENGTH). Consequently, the following function calls are equivalent:
/ADDRESS = 'ABCDE' /B = FILL(STRING=ADDRESS, LENGTH=18, SIDE=*LEFT, FILL-BYTE=C' ') /B = FILL('ABCDE', 18, *LEFT,C' ') /B = FILL(LENGTH=18, FILL-BYTE=C' ',STRING=ADDRESS, SIDE=*LEFT)
Input parameters can also be specified more than once in a function call. The last entry is always valid.
Example
DATE(FORMAT=*ISO, FORMAT=*GERMAN)
The date is returned in the *GERMAN format.