DEFINITION Strings; (* SJ *)

CONST EOF* = 4X; LF* = 0AX; CR* = 0DX; ESC* = 1BX;

CONST left* = 0; right* = 1; center* = 2; noadj* = 3; leftadd* = 4; 
      rightadd* = 5;

(* format codes for Adjust.
   left     : add character Fill in front of the number until Len is reached.
   right    : add character Fill at the end of the number until Len is reached.
   center   : add character Fill in front and at the end of the number until 
              Len is reached.
   noadj    : do not format the string.
   leftadd  : adds as much characters Fill as Len determines in front of
              the number.
   rightadd : adds as much characters Fill as Len determines in front of
              the number.
*)


TYPE ptr* = POINTER TO ARRAY 128 OF CHAR;


PROCEDURE End* (i : INTEGER; VAR String : ARRAY OF CHAR) : BOOLEAN;

(* Return TRUE if index i in String is past the end of the string *)


PROCEDURE SetEnd* (i : INTEGER; VAR String : ARRAY OF CHAR);

(* Sets an 0X at i if i is within the length of String *)


PROCEDURE Length* (VAR Strn : ARRAY OF CHAR) : INTEGER;

(* Returns the length of Strn *)


PROCEDURE AppendC* (c : CHAR; VAR Str : ARRAY OF CHAR);

(* Append character c to Str *)


PROCEDURE Append* (Str1 : ARRAY OF CHAR; VAR Str2 : ARRAY OF CHAR);

(* Append Str1 to Str2 *)


PROCEDURE Cap* (VAR c : CHAR);

(* converts c to its capital letter. German characters are converted too *)


PROCEDURE Caps* (VAR Strn : ARRAY OF CHAR);

(* converts a string to capital letters using Cap *)


PROCEDURE CAPs* (VAR Strn : ARRAY OF CHAR);

(* converts a string to capital letters using CAP. Is faster then Caps,
   but german characters are not converted.
*)

PROCEDURE Merge* (Str1,Str2 : ARRAY OF CHAR; VAR Str3 : ARRAY OF CHAR);

(* merges the string Str1 and Str2 and copies them into Str3 *)


PROCEDURE Delete* (BPos,EPos : INTEGER; VAR Strn : ARRAY OF CHAR);

(* deletes characters from BPos (incl.) to EPos (excl.) in Strn by copying
   the rest down to BPos.
*)

PROCEDURE Excerpt* (BPos,EPos : INTEGER; VAR Str1,Str2 : ARRAY OF CHAR);

(* excerpts characters from BPos (incl.) to EPos (excl.) in Str1 and copies
   it into Str2.
*)

PROCEDURE FPos* (Str1 : ARRAY OF CHAR; VAR Str2 : ARRAY OF CHAR) : INTEGER;

(* returns the position of the first appearence of string Str1 in Str2.
   Returns -1 if not found.
*)

PROCEDURE FPosC* (c : CHAR; VAR Str : ARRAY OF CHAR) : INTEGER;

(* returns the position of the first appearence of character c in Str.
   Returns -1 if not found.
*)

PROCEDURE LPos* (Str1 : ARRAY OF CHAR; VAR Str2 : ARRAY OF CHAR) : INTEGER;

(* returns the position of the last appearence of string Str1 in Str2.
   Returns -1 if not found.
*)

PROCEDURE LPosC* (c : CHAR; VAR Str : ARRAY OF CHAR) : INTEGER;

(* returns the position of the last appearence of character c in Str.
   Returns -1 if not found.
*)

PROCEDURE NPos* (BPos : INTEGER; Str1 : ARRAY OF CHAR;
                 VAR Str2 : ARRAY OF CHAR) : INTEGER;

(* returns the position of the next appearence of string Str1 in Str2.
   Search is started at BPos and continued to the end of Str2. Returns -1
   if not found.
*)

PROCEDURE NPosC* (BPos : INTEGER; c : CHAR; VAR Str : ARRAY OF CHAR)
                  : INTEGER;

(* returns the position of the next appearence of character c in Str.
   Search is started at BPos and continued to the end of Str. Returns -1
   if not found.
*)

PROCEDURE Insert* (Str1 : ARRAY OF CHAR; Pos : INTEGER;
                   VAR Str2 : ARRAY OF CHAR);

(* inserts Str1 at Pos in Str2. Str2 is copied towards the end to make
   space for Str1.
*)

PROCEDURE InsertC* (c : CHAR; Pos : INTEGER; VAR Str : ARRAY OF CHAR);

(* inserts character c at Pos in Str. Str is copied towards the end to make
   space for c.
*)

PROCEDURE Write* (Str1 : ARRAY OF CHAR; Pos : INTEGER;
                  VAR Str2 : ARRAY OF CHAR);

(* overwrites Str2 at Pos with Str1. If a 0X is overwritten, it will be
   added at the end.
*)

PROCEDURE Adjust* (Adj,Len : INTEGER; Fill : CHAR; VAR Strn : ARRAY OF CHAR);

(* formats a string. See constant definitions for the format options.
*)

END Strings.
