Prozeduren in Oberon

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]

AddressBook2.om
PROCEDURE SearchByName(addressBook: AddressBook;
                       name: Name;
                       VAR index: INTEGER) : BOOLEAN;
   (* search for the first entry with the given name
      in the address book;
      set index to its array index and return TRUE,
      if successful; return FALSE otherwise
   *)
BEGIN
   index := 0;
   WHILE (index < maxentries) &
         (~addressBook[index].used OR
            (addressBook[index].name # name)) DO
      INC(index);
   END;
   RETURN index < maxentries
END SearchByName;

*Prozeduren bestehen aus einem Namen (hier SearchByName), dann einer Reihe von formalen Parametern (hier addressBook, name und index), einem optionalen Typ bei Funktionen, lokalen Deklarationen (fehlen hier) und Programmtext.
 

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]
Copyright © 2004, 2005 Andreas Borchert, in HTML konvertiert am 18.02.2005