3. Statements : OpenROAD Language Statements : Callproc Statement
 
Share this page                  
Callproc Statement
This statement calls a procedure from a frame, a procedure, or a method for a user class. The callproc statement calls any of these types of procedures:
A global or local procedure written in 4GL
A procedure written in another high-level programming language (a 3GL language such as C or FORTRAN)
Note:  To call a database procedure, use the execute procedure statement (see Execute Procedure Statement).
This statement has the following syntax:
[returnvariable =] callproc procname[([parameterlist])];
You can call this procedure from a frame, a procedure, or a method for a user class. Because procname is a dynamic name, you can use an actual procedure name or a variable that resolves to a procedure name at runtime. If you use an actual procedure name, OpenROAD resolves the reference at compile time. If you use a variable, OpenROAD resolves the procedure reference at runtime. This difference in the timing of name resolution has an important consequence when the callproc statement is executed inside an included application.
To pass values to the called procedure, use the optional parameter list in the callproc statement. You can pass the parameters by value or by reference. To pass values by reference to a 4GL or 3GL procedure, use the byref(variable) option.
For more information about using the callproc statement to pass parameters by value and by reference, see the Programming Guide.
On returning from the called procedure, you can pass a single value back to the calling procedure or frame. The data type of the variable that receives the return value must be compatible with the return type of the called procedure. For database procedures, the return type is always integer.
If you use a variable to represent the procedure name so that the user can specify a procedure at runtime, you must ensure that the data type of the procedure's return value is compatible with that of any specified return variable. OpenROAD assumes that the return value's data type is the same as the return variable type. If the procedure attempts to return a value of an incompatible type, an error results at runtime.
Note:  You can also call a procedure as part of an expression. When you do so, the callproc keyword is not needed.