To call a procedure, use one of the following two forms:
procedure-expression "(" { argument ","
... } ")"
where argument = [ argument-name ":="]
expression
EVAL expression
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:
IO.Put("Hello"); (* Call a proper procedure *)
EVAL IO.GetLine(); (* Call a function procedure and throw away result *)
To return from a procedure, use the following statement:
RETURN [ expression ]
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.
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;