Go to the first, previous, next, last section, table of contents.

Procedure Call and Return Statements

To call a procedure, use one of the following two forms:

The first form is used to call a proper procedure (one that does not specify a return type and thus has no return value). The second is used to call a function procedure when you want to throw away the return value. For example:

To return from a procedure, use the following statement:

The RETURN statement is used inside procedures only to return control to the caller. A return value must be supplied if the procedure is a function procedure, but may not appear if the procedure is a proper procedure.


Example

PROCEDURE Warning (msg: TEXT) =
  BEGIN
    IO.Put ("warning: " & msg & "\n");
  END Warning;

PROCEDURE FindIndex (name: TEXT): INTEGER =
PROCEDURE FindAddress (name: TEXT): TEXT =
  VAR
    index := FindIndex(name);
  BEGIN
    IF index = -1 THEN
      (* Call the "Warning" procedure *)
      Warning ("could not find an address for " & name & ". Defaults used.\n")
      RETURN "123 Main Street USA";
    END;
    RETURN Address[i];
  END FindAddress;


Go to the first, previous, next, last section, table of contents.