Creating a Procedure is a way of setting apart part of a model that needs to be used several times in the model document. Such a model fragment can be used several times by calling the procedure at the appropriate spot in the model document.
Procedure declaration:
PROC proc_name ( parameter_1; parameter_2; ..., optional parameter list )
DO
ITP model part with declarations
OD
Rules:
Rules for the parameter list:
Where:
Constant parameters values cannot be changed within the procedure whereas the values of variable and array parameters can be changed by or in the procedure.
Note
Arrays and MAPs cannot be passed as CONST parameters.
Note
Recursive procedures cannot be used. Recursive procedures are procedures that call themselves either directly or indirectly.
APROC proc_name ( parameter_1; parameter_2; ..., the actual parameter list)
The number of parameters and their types in the actual parameter list must be the same as the parameter list in the declaration of the procedure.
Note
Definition:
PROC amount2 ( CONST NUMBER money ; TEXT result)
DO
NUMBER positive := money
IF money < 0
THEN
ASSIGN positive := - money
FI
ASSIGN result := number( positive ; 2)
IF money = 0
THEN
ASSIGN result := "-.-"
ELIF money < 0
THEN
ASSIGN result := result + " negative"
FI
OD
Use:
TEXT amount_text
APROC amount2 ( 23.14 ; amount_text)
#
€ @( amount_text)
#
APROC amount2 ( 0.0 ; amount_text)
#
€ @( amount_text)
#
A PROC can be used to separate any part of a model document whether it returns a value or not. Return values of a PROC must be explicitly brought outside the PROC by passing a variable to the PROC and assigning the result value to this variable. Before this variable can be used, it must be declared in the calling environment. For more information, refer to the example above; the variable amount_text is declared before it is used in the APROC call. A function, on the other hand, must be used when a return value is expected and needed.