DEFINITION MODULE InOutExtensions ;

(* written by 		   *)
(*    Jesse M. Heines	   *)
(*    University of Lowell *)

(* Version 1.2     1/28/87 *)



EXPORT QUALIFIED
   GetEscapeSequence, GetOneChar, ReadLn, ReadLine, WriteFormattedReal ;



PROCEDURE GetEscapeSequence
   (VAR c : ARRAY OF CHAR ) ;   (* characters read from the terminal *)

(* This procedure is designed to read as escape sequnce from the terminal   *)
(* without waiting for the user to press RETURN.  It begins by reading a    *)
(* single from the terminal.  If the character read is ESCape, a second     *)
(* character is read.  If the second characters is '[', a third character   *)
(* is read.  Any characters not read are set to 0C.                         *)


PROCEDURE GetOneChar
   (VAR c : CHAR ) ;   (* character read from terminal *)

(* This procedure gets a single character from the terminal without *)
(* waiting for the user to press RETURN.                            *)


PROCEDURE ReadLn ;

(* This procedure reads data from the current input stream until an end  *)
(* of line character (EOL), a null character (0C), or a CTRL/D character *)
(* (4C) is read.  The data read is not saved.  The purpose of this       *)
(* procedure is to skip the rest of the current line to prepare for      *)
(* reading the next line of input.                                       *)


PROCEDURE ReadLine
   (VAR line : ARRAY OF CHAR) ;   (* the line read *)

(* This procedure reads a line of data from the current input stream.     *)
(* Reading is terminated when the end of line character (EOL) is reached, *)
(* the array into which characters are being read becomes full, a null    *)
(* character is read, or a CTRL/D (4C) character (4C) is read.            *)


PROCEDURE WriteFormattedReal
   (r              : REAL ;         (* the real number to write *)
    width          : CARDINAL ;     (* size of output field *)
    ndecimalplaces : CARDINAL ) ;   (* number of decimal places to write *)

(* This procedure writes a real number to the output stream and places that *)
(* number in a field "width" spaces wide.  The field will be filled with    *)
(* blanks to pad it to the appropriate size.  (The number is right justi-   *)
(* fied in the field.)  WriteFormattedReal will output numbers in standard  *)
(* format with the specified number of decimal places.                      *)


END InOutExtensions.
