-- CharIO.Mesa
-- last edited by Johnsson on Jan 30, 1981 9:56 AM 
-- last edited by Satterthwaite on December 10, 1982 10:15 am 

DIRECTORY
  Format: TYPE USING [NumberFormat],
  Stream: TYPE USING [Handle],
  Strings: TYPE USING [String, SubString];

CharIO: DEFINITIONS = {

  Handle: TYPE = Stream.Handle;

 -- some control characters

  Control: PROC [c: CHAR] RETURNS [CHAR] = INLINE {
    RETURN [VAL[c.ORD-100b]]};
    
  NUL: CHAR = '\000;
  BS: CHAR = Control['H];
  TAB: CHAR = Control['I];
  LF: CHAR = Control['J];
  FF: CHAR = Control['L];
  CR: CHAR = Control['M];
  ControlZ: CHAR = Control['Z];
  ESC: CHAR = '\033;
  SP: CHAR = ' ;
  DEL: CHAR = '\177;

 -- numerical formats

  NumberFormat: TYPE = Format.NumberFormat;

 -- input/output

  GetChar: PROC [in: Handle] RETURNS [CHAR];

  PutChar: PROC [out: Handle, c: CHAR];

  GetString: PROC [Handle, Strings.String, PROC [CHAR] RETURNS [BOOL]];
  PutString: PROC [Handle, Strings.String];
  PutSubString: PROC [Handle, Strings.SubString];

  GetID, GetLine: PROC [Handle, Strings.String];
  PutLine: PROC [out: Handle, s: Strings.String];

  GetNumber: PROC [in: Handle, radix: CARDINAL] RETURNS [UNSPECIFIED];
  PutNumber: PROC [Handle, UNSPECIFIED, NumberFormat];

  GetOctal: PROC [in: Handle] RETURNS [UNSPECIFIED] = INLINE {
    RETURN [GetNumber[in, 8]]};
  PutOctal: PROC [Handle, UNSPECIFIED];

  GetDecimal: PROC [in: Handle] RETURNS [INTEGER] = INLINE {
    RETURN [GetNumber[in, 10]]};
  PutDecimal: PROC [Handle, INTEGER];

  }.