home *** CD-ROM | disk | FTP | other *** search
- Program ListPhoneBook;
-
- { A small Terminate utility to show how to use the phonebook }
-
- {$I PHONE.100}
-
- Var
- PhoneFile : File;
- x : Word;
-
- Procedure FatalError(s:string);
- Begin
- WriteLn('Fatal: '+s+#10#10);
- Halt;
- End;
-
- Begin
-
- FillChar(PHead,Sizeof(PHead),0);
- Assign(PhoneFile,'TERMINAT.FON');
- {$I-} Reset(PhoneFile,1); {$I+}
- If IOResult=0 Then
- Begin
-
- { Read the header in the phone file }
- {$I-} BlockRead(PhoneFile,PHead,Sizeof(PHead)); {$I+}
- If IOResult<>0 Then FatalError('Error in start of phonebook');
-
- { Read all records into structure }
- For x:=1 to PHead.Num Do
- Begin
- New(Ph[x]); { Reserve memory }
- {$I-} BlockRead(PhoneFile,Ph[x]^.P,Sizeof(Ph[x]^.P)); {$I+}
- If IOResult<>0 Then FatalError('Error in phonebook, maybe wrong version');
- End;
-
- Close(PhoneFile);
- End;
-
- { Write all phonenumbers on screen }
- For x:=1 to PHead.Num Do WriteLn(Ph[x]^.P.Name);
-
- { Free memory before exiting }
- For x:=1 to PHead.Num Do Dispose(Ph[x]);
-
- End.
-