home *** CD-ROM | disk | FTP | other *** search
- -- Chapter 22 - Programming exercise 2
- with Text_IO;
- use Text_IO;
- with Sequential_IO;
-
- procedure CH22_2 is
-
- type MY_REC is
- record
- Age : INTEGER;
- Sex : CHARACTER;
- Initial : CHARACTER;
- end record;
-
- package Int_IO is new Text_IO.Integer_IO(INTEGER);
- use Int_IO;
- package Seq_IO is new Sequential_IO(MY_REC);
- use Seq_IO;
-
- Myself, Other : MY_REC;
- My_In_File : Seq_IO.FILE_TYPE;
- Other_File : Seq_IO.FILE_TYPE;
-
- begin
-
- Open(My_In_File, In_File, "NAMEFILE.TXT");
- Open(Other_File, In_File, "OTHRFILE.TXT");
-
- for Index in 1..100 loop
- Read(My_In_File, Myself);
- Read(Other_File, Other);
- if (Myself.Age /= Other.Age) or
- (Myself.Sex /= Other.Sex) or
- (Myself.Initial /= Other.Initial) then
-
- Put("Record number");
- Put(Myself.Age);
- Put(" ");
- Put(Myself.Sex);
- Put(" ");
- Put(Myself.Initial);
-
- Put(Other.Age,12);
- Put(" ");
- Put(Other.Sex);
- Put(" ");
- Put(Other.Initial);
- New_Line;
- end if;
- end loop;
-
- Close(My_In_File);
- Close(Other_File);
-
- end CH22_2;
-
-
-
-
- -- Result of Execution
-
- -- Record number 50 M X 50 M O
- -- Record number 51 M X 51 M O
- -- Record number 52 M X 52 M O
- -- Record number 53 M X 53 M O
- -- Record number 54 M X 54 M O
- -- Record number 55 M X 55 M O
- -- Record number 56 M X 56 M O
- -- Record number 57 M X 57 M O
- -- Record number 58 M X 58 M O
- -- Record number 59 M X 59 M O
- -- Record number 60 M X 60 M O
-
-