While a variable will return the value last stored in it unmodified each time it is accessed, a function call causes an internal SDF-P algorithm to be executed that will supply a result. The purpose of the function determines which information will be accessed: while string processing and data conversion functions calculate the result value from the parameters supplied with the function call, other functions may supply information about the runtime environment (e.g. user ID, terminal name, date, time, file attributes) or return codes from previous command calls which they find by means of internal operating system calls.
Within an expression, a function is addressed via its name, followed by a list of parameters enclosed in parentheses. The list may be empty if the function does not require any parameters (e.g. the function TSN( ) which supplies the current task’s TSN) or if the preset parameter values are used. For instance, both function calls DATE( ) and DATE(FORMAT= *ISO) supply the current date in ISO format; the German format can be requested explicitly by means of the call DATE(FORMAT=*GERMAN). If the parameter list is empty, the parentheses may be omitted as well, provided the function name cannot be confused with a variable name.
Function parameters are specified in a similar way as SDF command operands: they can be addressed either via their position or their name, and their names may be abbreviated as long as they remain unequivocal. Parameter values may be keywords (prefixed by an asterisk) or expressions of one of the types STRING, INTEGER or BOOLEAN. Note that variable names are replaced by variable values when passed to a function. If the function is to access the variable name (e.g. to determine whether the variable has been defined), the name must be enclosed in quotes to identify it as a string constant; for example:
/ I = INDEX(FILE,'(')
/ B = IS-INITIALIZED('OUTPUT')
The first call accesses the contents of the string variable FILE and searches for the first occurrence of an opening parenthesis; the position of the parenthesis (or zero if no parenthesis is found) is assigned to variable I. The second command checks whether the variable OUTPUT has a valid value and assigns variable B either of the values TRUE or FALSE, depending on the result of the check.
In addition to the predefined functions supplied with SDF-P, there are system administration functions that may be implemented by the system administrator and made available to all users, if required.
The description of all predefined functions and their parameters starts on page "Predefined functions ". A detailed description of the notation for function parameters is contained in section “Inputparameters in function calls” (Input parameters in function calls ).