DEFINITION MODULE StrUtils;

EXPORT QUALIFIED
                 Error,        (* Global error flag for hierarchy *)
                 ErrorString,  (* Last culprit *)
                 
                 STRptr,       (* Pointer to a string taken from heap *)
                 s,            (* Routine to put string on heap *)
                 
                 Parse,        (* Parse ("Fred = Jim", F, "=", J)
                                   returns TRUE and puts "Fred" in F
                                   and "Jim" in J.
                                  Returned strings are space-compressed *)
                 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 *)
                 Length,        (* No. of bytes which would be printed
                                    if passed to WriteS *)
                 Readln;        (* Read line with prompt. *)

CONST
   FuckingBig = 100000;

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

VAR
   Error       :BOOLEAN;
   ErrorString :STRptr;

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 Length (VAR S :ARRAY OF CHAR) :INTEGER;

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

END StrUtils.
