Global Procedures
A global 4GL procedure is a routine written in 4GL that you can call by name from a script or another procedure. The procedure is a component of an application and is stored in the application's database.
To create a global 4GL procedure, use the OpenROAD Workbench to name the procedure and declare its return value. You then write the actual procedure statement in 4GL. The following section describes this statement. For more information about creating 4GL procedures, see the Workbench User Guide.
Procedure Statement
The procedure statement defines a 4GL procedure. This statement declares the parameters for the procedure and provides the actual processing statements. The syntax for a global 4GL procedure is:
procedure procname [([parameterlist}])] =
[declare
[localvariablelist]
[localprocedureforwardreferences]
enddeclare]]
begin
statementlist
end[;]
{localprocedure[;]}
procname
Specifies the procedure name. You use this name when you call the procedure in the application.
parameterlist
Specifies parameters that are passed to the procedure. You can also use a parameter as a local variable within the procedure. A 4GL procedure can have any number of parameters.
A parameter can be any simple data type acceptable to OpenROAD or any named user class or system class. If a procedure has no parameters, the parentheses are optional.
statementlist
Includes any OpenROAD statement
For a complete description of the procedure statement, see the Language Reference Guide online help.
For more information about local procedures, see
Local Procedures.
Returning from a Procedure
Use the return statement in your procedure to return control to the script or procedure that called it. In returning control, you can also pass a value back to the calling script or procedure. The single value that you pass back must match the return value data type that you specified when you created the procedure. The value is passed back to the caller and assigned as the value of the return variable in the calling script or procedure.
You can use a procedure that returns a value as an expression by itself or as part of a larger expression, as described in Procedures in Expressions. The data type of the returned value must be compatible with the requirements of the expression. In the following example, square_root is a procedure that returns a value.
returnfield = square_root(number = 36) * 5;
A procedure that returns a value can be used as a parameter value in another procedure. The following is an example of nested OpenROAD procedures:
returnfield = p (arg1 = square_root(number = 17));
The following example calls the procedure with the name specified in the procfield field of the current frame and returns a value to the result variable:
result = :procfield (x = 5, y = price);
If you use the value found in a variable for the procedure name, you must use the colon. At runtime, the user enters the correct procedure name into procfield on the current form, and OpenROAD then calls that procedure.
For more information about callproc, see the Language Reference Guide online help.
Last modified date: 12/20/2023