The Function component can be provided as a system or end-user defined object. User-defined Functions can be User Functions or Report Procedures. System Functions are, and User-defined Functions can be structured to perform small tasks within a larger task. Functions are packaged (encapsulated) mini-procedures that can then be used in construction of other Functions and Reports, where they are represented only by their original entry and exit points (Parameters and/or Return values).
This ability to downsize Procedures through the use of Functions to a narrower scope can greatly simplify construction of complex Procedures and Reports. Conceptually, it is easier to deal with a number of relatively small and simple building blocks, each of which performs a specific function, rather than to design and debug a large, convoluted Procedure that houses all calculations, data retrievals, conditions etc. that make up the logic of a Procedure.
The "Parameters" box in the Function component corresponds to the Parameters component in the body of the selected Function, and is pre-filled with the name(s) of the parameters as defined within that Function. For visual confirmation, see the corresponding Parameters component shown immediately to the right of the Function component, in our example.
The variables shown in the expanded Function component must be filled with the procedure variables that will either carry data into the Function, or bring the results of the Function's execution back into the calling procedure. Therefore, the parameter names of the Function component should be replaced with the variables from the calling procedure, where the Function is used.
In a similar way, the "Return value" box in the expanded Function component corresponds to the Return component defined in the Function, and should be filled with the variable that receives the return value from the Function.
Some Functions (in fact, all User-defined Functions and most of the System Functions) allow passing of data in the Parameters box either through the procedure variables (default setting), or by hard-coded values. Passing of data through variables is accomplished by:
If the Run-time switch is pressed, so that its color is changed to white, then the contents of the field next to the switch is interpreted as the data itself, rather than the name of the variable that carries the data.
Reports in Function components
If the Function component encapsulates a Report Procedure, it produces the report at the run-time. The report is displayed in a new window, if the Procedure that calls the Report runs in the foreground, or it is saved in the configuration database in the case of the background execution.
For the Function components with Report Procedures the Legend Inspector displays the "Display report" checkbox, in addition to the standard function info:
The checkbox, if left unchecked, suppresses the display of the report in the foreground and in the background. This feature can be useful if the report produced by the Function component is intended to be e-mailed as a PDF attachment, and does not need to be viewed by the user.