(**********************************************************************

    :Program.    StringOps.def
    :Contents.   string operations, replaces the standard module "Strings".
    :Author.     Nicolas Benezan [bne]
    :Address.    Postwiesenstr. 2, D7000 Stuttgart 60
    :Phone.      711/333679
    :Copyright.  Public Domain
    :Language.   Modula-2
    :Translator. M2Amiga A+L V3.2d
    :History.    V1.0c [bne] 18.Apr.1989

**********************************************************************)

DEFINITION MODULE StringOps;

(* All procedures will truncate the string if it was too long to
   fit into the array boundaries. *)

PROCEDURE Append(VAR String:ARRAY OF CHAR;
                     Tail:ARRAY OF CHAR);
(*:Semantic.    Appends <Tail> to <String>
*)

PROCEDURE AppendChar(VAR String:ARRAY OF CHAR;
                         Char:CHAR);
(*:Semantic.    Appends a single character to <String>
*)

PROCEDURE Assign(    Source:ARRAY OF CHAR;
                 VAR Destination:ARRAY OF CHAR);
(*:Semantic.    Copies <Source> to <Destination>.
*)

PROCEDURE CapChar(VAR Char:CHAR);
(*:Semantic.    Returns the capital letter of <Char>
  :Note.        works also with foreign letters (äöüßáè...)
*)

PROCEDURE CapString(VAR String:ARRAY OF CHAR);
(*:Semantic.    CapChar()s each character of <String>
*)

PROCEDURE FindChar(String:ARRAY OF CHAR;
                   Char:CHAR;
                   Start:INTEGER):INTEGER;
(*:Semantic.    Searches next occurence of <Char> in <String>
  :Input.       Start: position where to start searching
  :Result.      position of <Char> in <String>
  :Result.      or -1 if <Char> is not found
*)

PROCEDURE Compare(String1,String2:ARRAY OF CHAR):INTEGER;
(*:Semantic.    Compares <String1> vs <String2>
  :Result.      0 if they are equal
  :Result.      <0 if String1 < String2
  :Result.      >0 if String1 > String2
*)

PROCEDURE Concat(    Head:ARRAY OF CHAR;
                     Tail:ARRAY OF CHAR;
                 VAR String:ARRAY OF CHAR);
(*:Semantic.    concatenates <Head> and <Tail> to <String>
*)

PROCEDURE DeleteSubString(VAR String:ARRAY OF CHAR;
                              Start,Len:INTEGER);
(*:Semantic.    Deletes a substring of <String> which starts
  :Semantic.    at position <Start> and is <Len> characters
  :Semantic.    long.
*)

PROCEDURE FindSubString(String:ARRAY OF CHAR;
                        SubString:ARRAY OF CHAR;
                        Start:INTEGER):INTEGER;
(*:Semantic.    Searches next occurence of <SubString> in <String>
  :Input.       Start: position where to start searching
  :Result.      next position of <SubString> in <String>
  :Result.      or -1 if not found
*)

PROCEDURE InsertSubString(VAR String:ARRAY OF CHAR;
                              SubString:ARRAY OF CHAR;
                              Position:INTEGER);
(*:Semantic.    Inserts <SubString> into <String> at <Position>
*)

PROCEDURE InsertChar(VAR String:ARRAY OF CHAR;
                         Char:CHAR;
                         Position:INTEGER);
(*:Semantic.    Inserts a single character into <String> at <Position>
*)

PROCEDURE Length(String:ARRAY OF CHAR):INTEGER;
(*:Result.      Length of <String>
*)

PROCEDURE OverWrite(VAR String:ARRAY OF CHAR;
                        Overlay:ARRAY OF CHAR;
                        Position:INTEGER);
(*:Semantic.    Replaces (overwrites) the caracters of <String> with
  :Semantic.    <Overlay> starting at <Position>.
*)

PROCEDURE SubString(    Source:ARRAY OF CHAR;
                    VAR Destination:ARRAY OF CHAR;
                        Position,Len:INTEGER);
(*:Output.      Destination: the substring of <String> which starts
  :Semantic.    at position <Start> and is <Len> characters long.
*)

END StringOps.

