2. Writing Scripts and Procedures : Procedures : Global Procedures : Returning from a Procedure
 
Share this page                  
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.