Search procedure in modula 2
Geplaatst: wo 20 jan 2010, 22:41
Code: Selecteer alles
...
CONST
SIZE = ...; (*Number of records in array *)
...
TYPE
KeyType = ...;
(* any type accepting relational operators *)
ArrayType = ARRAY[0..Size] OF RecordType;
RecordType = RECORD
Key : KeyType;
...
END
...
VAR
Data : ArrayType;
Key : KeyType;
Found: [0..Size];
...
BEGIN
...
Key := ...;
Found := Search(Data,Key);
IF Found = 0
THEN WrStr(“Item not found”)
ELSE (* Write contents of Data[Found] *)
...
END (* IF *);
...
Klopt het dat de Found een out-of-range detectie vervult in bovenstaande code?
Alvast bedankt!