home *** CD-ROM | disk | FTP | other *** search
- -- Chapter 22 - Programming exercise 3
- with Text_IO;
- use Text_IO;
- with Sequential_IO;
-
- procedure CH22_3 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 : MY_REC;
- My_Out_File : Seq_IO.FILE_TYPE;
- My_In_File : Seq_IO.FILE_TYPE;
-
- begin
-
- Create(My_Out_File, Out_File, "NAMEFILE.TXT");
-
- Myself.Sex := 'M';
- Myself.Initial := 'X';
-
- for Index in 1..100 loop
- Myself.Age := Index;
- Write(My_Out_File, Myself);
- end loop;
-
- Close(My_Out_File);
-
- Open(My_In_File, In_File, "NAMEFILE.TXT");
-
- for Index in 1..100 loop
- Read(My_In_File, Myself);
- if Myself.Age >= 82 then
- Put("Record number");
- Put(Myself.Age);
- Put(" ");
- Put(Myself.Sex);
- Put(" ");
- Put(Myself.Initial);
- New_Line;
- end if;
- end loop;
-
- Close(My_In_File);
-
- end CH22_3;
-
-
-
-
- -- Result of Execution
-
- -- Record number 82 M X
- -- Record number 83 M X
- -- Record number 84 M X
- -- Record number 85 M X
- -- Record number 86 M X
- -- Record number 87 M X
- -- Record number 88 M X
- -- Record number 89 M X
- -- Record number 90 M X
- -- Record number 91 M X
- -- Record number 92 M X
- -- Record number 93 M X
- -- Record number 94 M X
- -- Record number 95 M X
- -- Record number 96 M X
- -- Record number 97 M X
- -- Record number 98 M X
- -- Record number 99 M X
- -- Record number 100 M X
-
-