Appendix E Simple_io package The simple_io package is the simplified I/O package used by the first year students. It attempts to provide facilities similar to that found in the Turbo Pascal environment. with text_io; package simple_io is data_error: exception renames text_io.data_error; procedure get_line( item : out integer); procedure get_line( file :in out text_io.file_type; item : out integer); procedure get_line( item : out float); procedure get_line( file :in out text_io.file_type; item : out float); procedure get_line( item : out string); procedure get_line( file :in out text_io.file_type; item : out string); procedure get_line( item : out character); procedure get_line( file :in out text_io.file_type; item : out character); procedure get( item : out character) renames text_io.get; procedure skip_line(spacing :in text_io.positive_count:=1) renames text_io.skip_line; function end_of_file return boolean renames text_io.end_of_file; function end_of_line return boolean renames text_io.end_of_line; procedure put( item :in integer; width :in natural := 0); procedure put( file :in out text_io.file_type; item :in integer; width :in natural := 0); default_fore :natural := 6; default_aft :natural := 2; default_exp :natural := 0; procedure put( item :in float; fore :in natural := default_fore; aft :in natural := default_aft; exp :in natural := default_exp); procedure put( file :in out text_io.file_type; item :in float; fore :in natural := default_fore; aft :in natural := default_aft; exp :in natural := default_exp); procedure put( item :in string; width :in natural := 0); procedure put( item :in character); procedure new_line(line_count:in positive := 1); ------------------------------------------------------------ -- The following subprograms are used for screen and keyboard control -- subtype row_range is integer range 0..23; subtype column_range is integer range 0..79; procedure move( row :in row_range; col :in column_range); procedure home; -- moves the cursor to row_range'first, column_range'first procedure clear_screen; -- clears the screen and sends the cursor home subtype color_range is integer range 30..37; black :constant color_range := 30; red :constant color_range := 31; green :constant color_range := 32; yellow :constant color_range := 33; blue :constant color_range := 34; magenta :constant color_range := 35; cyan :constant color_range := 36; white :constant color_range := 37; procedure text_color(color :color_range); function current_text_color return color_range; -- what is the current color used for displaying text? procedure get_cursor_pos(row : out row_range; col : out column_range); -- where is the cursor currently positioned? procedure wait_for_keypress; -- waits until the user hits a single key function read_key return character; -- returns the key the user types without needing -- the user to press the return key. end simple_io;