Go to the first, previous, next, last section, table of contents.
The Text interface provides procedures that work on strings. The
`T' type in the procedure declarations below is really the built-in
type `TEXT'.
- PROCEDURE Equal(t, u: T): BOOLEAN;
- Return "TRUE" if "t" and "u" have the same length and
(case-sensitive) contents.
- PROCEDURE Compare(t1, t2: T): [-1..1];
- Compares strings "t1" and "t2" using lexicographic rules. Returns:
- -1 if "t1" < "t2"
- 0 if "t1" = "t2"
- +1 if "t1" > "t2"
- PROCEDURE GetChar(t: T; i: CARDINAL): CHAR;
- Return the i'th character of "t", i IN [0..LENGTH(t)-1].
It is a checked runtime error if i >= Length(t).
- PROCEDURE Length(t: T): CARDINAL;
- Return the number of characters in "t".
- PROCEDURE Empty(t: T): BOOLEAN;
- Equivalent to "Length(t) = 0".
- PROCEDURE Sub(t: T; start: CARDINAL; length: CARDINAL := LAST(CARDINAL)): T;
- Return a sub-sequence of "t": empty if "start >= Length(t)" or
"length = 0"; otherwise the subsequence ranging from "start" to the
minimum of "start+length-1" and "Length(t)-1".
- PROCEDURE FindChar(t: T; c: CHAR; start := 0): INTEGER;
- If "c = t[i]" for some "i" in "[start~..~Length(t)-1]", return the
smallest such "i"; otherwise, return -1.
- PROCEDURE SetChars(VAR a: ARRAY OF CHAR; t: T);
- For each "i" from 0 to "MIN(LAST(a), Length(t)-1)", set "a[i]" to
"GetChar(t, i)".
- PROCEDURE FromChar(ch: CHAR): T;
- Return a text containing the single character "ch".
- PROCEDURE FromChars(READONLY a: ARRAY OF CHAR): T;
- Return a text containing the characters of "a".
- PROCEDURE Hash(t: T): Word.T;
- Return a hash function of the contents of "t".
- PROCEDURE FindCharR(t: T; c: CHAR; start := LAST(INTEGER)): INTEGER;
- If "c = t[i]" for some "i" in "[0~..~MIN(start, Length(t)-1)]",
return the largest such "i"; otherwise, return -1.
Go to the first, previous, next, last section, table of contents.