DEFINITION MODULE Utils;

EXPORT QUALIFIED
                 SuppressError,
                 
                 FlushErrors,
                 ReportError,
                 SetModule,
                 SetError,
                 ReportWarning,

                 Warning,      (* Global error flags for                  *)
                 Error,        (* hierarchical error recovery             *)
                 
                 ModuleString,
                 ErrorString,  (* Last culprit                            *)
                 CulpritString,
                 
                 STRptr,       (* Pointer to a string taken from heap     *)
                 s,            (* Routine to put string on heap           *)
                 
                                  
                 IsInt,         (* TRUE if param is an integer            *)
                 IntOf,         (* String to integer conversion           *)
                 
                 Equals,        (* String equality test                   *)
                 AlmostEquals,  (* TRUE is first string equals or
                                    starts second                         *)
                                    
                 Spaces,        (* Prints a number of spaces              *)
                 DeTrail,       (* Removes trailing spaces from a string  *)
                 
                 Assign,        (* Copies one string to another.
                                    Guarantees null-termination on output *)
                 Append,        (* Appends string to first param          *)
                 Length,        (* No. of bytes which would be printed
                                    if passed to WriteS                   *)
                                    
                 Readln;        (* Read line with prompt.                 *)

CONST

   FuckingBig = 1023;

TYPE

   STRptr  =  POINTER TO ARRAY [0..FuckingBig] OF CHAR;

VAR
   
   SuppressError,
   
   Warning,
   Error       :BOOLEAN;

   ModuleString,
   ErrorString,
   CulpritString :STRptr;

PROCEDURE ReportError   (Module, Error, Culprit :ARRAY OF CHAR);

PROCEDURE ReportWarning (Module, Error, Culprit :ARRAY OF CHAR);

PROCEDURE SetModule     (Module :ARRAY OF CHAR);

PROCEDURE SetError      (Error  :ARRAY OF CHAR);

PROCEDURE FlushErrors ();


PROCEDURE s (S :ARRAY OF CHAR) :STRptr;

PROCEDURE Parse (In     :ARRAY OF CHAR;
             VAR Out1   :ARRAY OF CHAR;
                 Split  :CHAR;
             VAR Out2   :ARRAY OF CHAR) :BOOLEAN;

PROCEDURE IsInt (Int :ARRAY OF CHAR) :BOOLEAN;

PROCEDURE IntOf  (Int :ARRAY OF CHAR) :INTEGER;

PROCEDURE Equals (S1, S2 :ARRAY OF CHAR) :BOOLEAN;

PROCEDURE AlmostEquals (S1, S2 :ARRAY OF CHAR) :BOOLEAN;

PROCEDURE Spaces (I :INTEGER);

PROCEDURE DeTrail (VAR S :ARRAY OF CHAR);

PROCEDURE Assign (From :ARRAY OF CHAR; VAR To :ARRAY OF CHAR);

PROCEDURE Append (VAR S :ARRAY OF CHAR; S1 :ARRAY OF CHAR);

PROCEDURE Length (VAR S :ARRAY OF CHAR) :INTEGER;

PROCEDURE Readln (PromptStr :ARRAY OF CHAR; VAR Line :ARRAY OF CHAR);

END Utils.
