VMS Help  —  PASCAL  Statements  RETURN  Example
  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.
Close Help