type personInfo = Record // definition of the Record the Name: String [10]; Age: Integer; End; // write key record includes adding a new record Procedure WriteRec; var NewRec: PersonInfo; // declare variables Rec F: File of PersonInfo; // file type variable Rec RecFileName: ShortString; // save the full file name Rec RecCount: integer; // number Rec the begin NewRec.Name:=NameEdit.Text; // get the data from the interface NewRec.Age: = StrToInt ( AgeEdit.Text); RecFileName: = 'C: \ PersonInfo.Rec'; AssignFile (F., RecFileName); iF the FileExists (RecFileName) <> // True the then determines whether the file exists the begin Rewrite (F.); // does not exist, new document the Write (F., NewRec); End the else the begin FileMode: =. 1; // disposed WriteOnly mode Reset (F); // Add Rec the file exists RecCount: = FileSize (F); // get the number Rec Seek (F, RecCount); // Pointer position provided the Write (F., NewRec); End; CloseFile (F.); // close the file End; // read record ReadRec Procedure; var GetRec: PersonInfo; F: file of PersonInfo; RecFileName: ShortString; // save the file name Rec RecCount: Integer; Rec location // the user wants to read RecMax: integer; // Rec maximum begin RecFileName: = 'C: \ PersonInfo.Rec'; RecCount: = StrToInt (CountEdit.Text) -1; // user wants to extract a first input 1, and so AssignFile (F., RecFileName); IF the FileExists (RecFileName) < > True the then Exit; FileMode: = 0; the Reset (F.); RECMAX: = FileSize (F.); IF RecCount> RECMAX the then-the Exit. 1; // jump exceeds the maximum Rec Seek (F, RecCount); // set the read Pointer Rec position the Read (F., GetRec); ShowMessage (GetRec.Name + IntToStr (GetRec.Age)); End;