--============================================================================= --| --| TASK NAME: numbers.search.process_normal_input --| --| ALGORITHM/STRATEGY: Search parameters are read from file and, for each --| set, entry do_search.enter_start_search is called. --| --| NOTES: None. --| --============================================================================= WITH other_io; WITH text_io; SEPARATE (numbers.search) TASK BODY process_normal_input IS -- Input file input : text_io.file_type; -- Order of PDIs to be sought order : natural; -- Radix of PDIs to be sought radix : numbers.radix_range; -- Length of PDIs to be sought search_length : numbers.digit_range; -- Exception raised for any error related to opening input file file_open_error : EXCEPTION; BEGIN -- process_normal_input SELECT -- Wait for signal to begin reading file ACCEPT start; BEGIN -- Open input file text_io.open (file => input, mode => text_io.in_file, name => "input.dat"); EXCEPTION WHEN text_io.name_error => text_io.new_line; text_io.put_line ("Cannot find file ""input.dat"""); RAISE file_open_error; WHEN text_io.use_error => text_io.new_line; text_io.put_line ("Cannot open file ""input.dat"""); RAISE file_open_error; WHEN OTHERS => text_io.new_line; text_io.put_line ("Problem encountered opening file " & """input.dat"""); RAISE file_open_error; END; -- Process search parameters until end-of-file reached WHILE (NOT text_io.end_of_file(input)) LOOP -- Read parameters other_io.natural_io.get(input, radix); other_io.natural_io.get(input, order); other_io.natural_io.get(input, search_length); text_io.skip_line(file => input); -- Call entry to begin search search.do_search.enter_start_search (radix, order, search_length); END LOOP; ABORT monitor_keyboard; OR TERMINATE; END SELECT; EXCEPTION WHEN file_open_error => text_io.new_line; text_io.put_line ("Terminating program"); text_io.new_line; ABORT monitor_keyboard; WHEN text_io.data_error => text_io.new_line; text_io.put_line ("Error reading file ""input.dat"""); text_io.new_line; text_io.put_line ("Terminating program"); text_io.new_line; ABORT monitor_keyboard; WHEN text_io.end_error => text_io.new_line; text_io.put_line ("End-of-file error reading file ""input.dat"""); text_io.new_line; text_io.put_line ("Terminating program"); text_io.new_line; ABORT monitor_keyboard; WHEN OTHERS => text_io.new_line; text_io.put_line ("Program error encountered"); text_io.new_line; text_io.put_line ("Terminating program"); text_io.new_line; ABORT monitor_keyboard; END process_normal_input;