VMS Help
PASCAL, Statements, RETURN
*Conan The Librarian (sorry for the slow response - running on an old VAX)
|
|
The RETURN statement passes control back to the caller of a
PROCEDURE, FUNCTION, PROGRAM, or module initialization or
finalization section. A RETURN statement is equivalent to a
GOTO to a label placed just before the END of the body, and in a
PROGRAM, has the effect of stopping the program
Syntax:
RETURN [ return-value ]
Inside a FUNCTION, return-value specifies an ending value for
the FUNCTION. If no return-value is provided, the last value
assigned to the function identifier is used as the function
result. The return-value type and function type must be the
same.
Inside a PROGRAM, the return-value specifies an ending value for
the PROGRAM. If you do not provide a b
return-value, Compaq Pascal uses the value 1 on OpenVMS
systems.
Inside a PROCEDURE, module initialization section, or module
finalization section, Compaq Pascal generates an error.
FUNCTION FindFirst(StartingPoint: INTEGER) : INTEGER;
VAR i: INTEGER;
BEGIN
FOR i := StartingPoint TO MaximumNumber DO
BEGIN
IF Data[i] = Suitable THEN
BEGIN
AttributesOfDesiredData = Attributes[i];
Subscript := i;
RETURN i;
END;
END;
END;
The example shows the usage of RETURN ststement. In the
example, a function searches through the array called "Data" for
an element that matches "Suitable". When it finds one, it
assigns values to two global variables and executes a RETURN.
Omitting the RETURN statement would make the function continue
processing; it would assign values for the last suitable element
instead of the first.
[legal]
[privacy]
[GNU]
[policy]
[netiquette]
[sponsors]
[FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.