home *** CD-ROM | disk | FTP | other *** search
- -- Chapter 14 - Program 5
- with Text_IO;
- use Text_IO;
-
- procedure StringIn is
-
- package Int_IO is new Text_IO.Integer_IO(INTEGER);
- use Int_IO;
-
- My_File : FILE_TYPE;
- My_String : STRING(1..10);
-
- begin
-
- Open(My_File,In_File,"CHARACTS.TXT");
-
- loop -- Read one string at a time and display it
- exit when End_Of_File(My_File);
- Get(My_File,My_String);
- Put(My_String);
- end loop;
- New_Line(2);
-
- Reset(My_File); -- Reset and start over with the same file
-
- loop -- Read and display but search for End of lines
- exit when End_Of_File(My_File);
- Get(My_File,My_String);
- Put(My_String);
- if End_Of_Line(My_File) then
- Put_Line("<--- End of line found");
- else
- Put_Line("<--- 10 characters");
- end if;
- end loop;
- New_Line;
-
- Close(My_File);
-
- end StringIn;
-
-
-
-
- -- Result of execution
-
- -- (Note; The first line is a full 80 columns wide.)
- -- This line goes to the CHARACTS.TXT file.This line goes to ...
- -- This line goes to the CHARACTS.TXT file.
- --
- -- This line <--- 10 characters
- -- goes to th<--- 10 characters
- -- e CHARACTS<--- 10 characters
- -- .TXT file.<--- End of line found
- -- This line <--- 10 characters
- -- goes to th<--- 10 characters
- -- e CHARACTS<--- 10 characters
- -- .TXT file.<--- End of line found
- -- This line <--- 10 characters
- -- goes to th<--- 10 characters
- -- e CHARACTS<--- 10 characters
- -- .TXT file.<--- End of line found
-
-