Return

Return

Top  Previous  Next

Occasionally it is desirable to return from a procedure at a point other than its normal end. This is done using a "return" statement. "Return" forces a procedure to immediately return to its caller. At the end of a procedure, a "return" is implied and need not be written.

 

The TestGuess procedure used in the number guessing program can be rewritten using a "return" statement:

 

        procedure TestGuess;

        begin

        if Guess = Number then [Text(0, "Correct!");   return];

        if Guess > Number then Text(0, "Too high")

                else Text(0, "Too low");

        CrLf(0);

        end;