DEFINITION MODULE Strings; (* Note: truncation of strings may occur if the user does not provide large enough variables to contain the result of the operation. *) (* Strings are of type ARRAY OF CHAR, and their length is the size of the array, unless a 0-byte occurs in the string to indicate the end of the string. *) PROCEDURE Assign(source: ARRAY OF CHAR; VAR dest: ARRAY OF CHAR); (* Assign string source to dest *) PROCEDURE Insert(substr: ARRAY OF CHAR; VAR str: ARRAY OF CHAR; inx: CARDINAL); (* Insert the string substr into str, starting at str[inx]. If inx is equal to or greater than Length(str) then substr is appended to the end of str. *) PROCEDURE Delete(VAR str: ARRAY OF CHAR; inx, len: CARDINAL); (* Delete len characters from str, starting at str[inx]. If inx >= Length(str) then nothing happens. If there are not len characters to delete, characters to the end of the string are deleted. *) PROCEDURE Pos(substr, str: ARRAY OF CHAR): CARDINAL; (* Return the index into str of the first occurrence of substr. Pos returns a value greater than HIGH(str) of no occurrence is found. *) PROCEDURE Copy(str: ARRAY OF CHAR; inx, len: CARDINAL; VAR result: ARRAY OF CHAR); (* Copy at most len characters from str into result, starting at str[inx]. *) PROCEDURE Concat(s1, s2: ARRAY OF CHAR; VAR result: ARRAY OF CHAR); (* Concatenate two strings. *) PROCEDURE Length(str: ARRAY OF CHAR): CARDINAL; (* Return number of characters in str. *) PROCEDURE CompareStr(s1, s2: ARRAY OF CHAR): INTEGER; (* Compare two strings, return -1 if s1 < s2, 0 if s1 = s2, and 1 if s1 > s2. *) END Strings.