DEFINITION MODULE InOut;

(* (C) Copyright 1993 Marcel Timmermans. All rights reserved. *)

FROM SYSTEM IMPORT WORD,ADDRESS;

CONST
    EOL = 36C;

VAR
    Done    :BOOLEAN;
    termCH  :CHAR;

PROCEDURE Read( VAR ch :CHAR );
(*
    read a character
*)

PROCEDURE ReadString( VAR s :ARRAY OF CHAR );
(*
    read a string.
    input is terminated by a ' ', or any control character except BS or DEL.
    the terminating character is saved in termCH.
    when reading from the terminal, editing of the input is available:
        ASCII.BS deletes the last characted input
        ASCII.DEL deletes all characters input
        ASCII.ESC deletes all characters input and returns
*)

PROCEDURE ReadInt( VAR x :INTEGER );
(*
    a string is read from the input device and is then converted to
    an INTEGER.
*)

PROCEDURE ReadLongInt( VAR x :LONGINT );
(*
    a string is read from the input device and is then converted to
    a LONGINT.
*)


PROCEDURE ReadCard(VAR x: CARDINAL);
(*
    a string is read from the input device and is then converted to
    a CARDINAL.
*)

PROCEDURE ReadLongCard(VAR x: LONGCARD);
(*
    a string is read from the input device and is then converted to
    a LONGCARD.
*)

PROCEDURE Write( ch :CHAR );
(*
    write the character
*)

PROCEDURE WriteLn;
(*
    same as: Write( ASCII.EOL )
*)

PROCEDURE WriteString( s :ARRAY OF CHAR );
(*
    write the string out
*)

PROCEDURE WriteLine( s :ARRAY OF CHAR );
(*
    same as: WriteString( s ); WriteLn;
*)

PROCEDURE WriteInt( x :LONGINT; n :CARDINAL );
(*
    write the INTEGER right justified in a field of at least n characters.
*)

PROCEDURE WriteCard( x : LONGCARD; n : CARDINAL);
(*
    write the CARDINAL right justified in a field of at least n characters.
*)

PROCEDURE WriteOct( x, n :CARDINAL );
(*
    write x in octal format in a right justified field of at least n characters.
    IF (n <= 3) AND (x < 100H) THEN 3 digits are written
    ELSE 6 digits are written
*)

PROCEDURE WriteHex( x :LONGINT; n :CARDINAL );
(*
    write x in hexadecimal in a right justified field of at least n characters.
    IF (n <= 2) AND (x < 100H) THEN 2 digits are written
    ELSE 4 digits are written
*)

PROCEDURE WriteFormat(template : ARRAY OF CHAR;
                      data : ADDRESS);

END InOut.