home *** CD-ROM | disk | FTP | other *** search
- -- Chapter 22 - Programming exercise 1
- with Text_IO;
- use Text_IO;
- with Sequential_IO;
-
- procedure CH22_1 is
-
- type MY_REC is
- record
- Age : INTEGER;
- Sex : CHARACTER;
- Initial : CHARACTER;
- end record;
-
- package Seq_IO is new Sequential_IO(MY_REC);
- use Seq_IO;
-
- Myself : MY_REC;
- My_Out_File : Seq_IO.FILE_TYPE;
- Other_File : Seq_IO.FILE_TYPE;
- begin
-
- Create(My_Out_File, Out_File, "NAMEFILE.TXT");
- Create(Other_File, Out_File, "OTHRFILE.TXT");
-
- Myself.Sex := 'M';
- for Index in 1..100 loop
- Myself.Age := Index;
- Myself.Initial := 'X';
- Write(My_Out_File, Myself);
- if (Myself.Age >= 50) and (Myself.Age <= 60) then
- Myself.Initial := 'O';
- Write(Other_File, Myself);
- else
- Write(Other_File, Myself);
- end if;
- end loop;
-
- Close(My_Out_File);
- Close(Other_File);
-
- end CH22_1;
-
-
-
-
- -- Result of Execution
-
- -- (The output is a binary file named NAMEFILE.TXT,
- -- and a binary fiel named OTHRFILE.TXT.)
-
-