# The Text interface

    INTERFACE Text;

    TYPE
      T = TEXT;

A non-nil `TEXT` represents a zero-based sequence of characters. `NIL` does not represent any sequence of characters, it will not be returned from any procedure in the interface, and it is a checked runtime error to pass it to any procedure in the interface.

    PROCEDURE Cat(t, u: T): T;

The concatenation of `t` and `u`.

    PROCEDURE Equal(t, u: T): BOOLEAN;

`TRUE` if `t` and `u` have the same length and (case-sensitive) contents.

    PROCEDURE GetChar(t: T; i: CARDINAL): CHAR;

Character `i` of `t`. A checked runtime error if `i >= Length(t)`.

    PROCEDURE Length(t: T): CARDINAL;

The number of characters in `t`.

    PROCEDURE Empty(t: T): BOOLEAN;

`TRUE` if `Length(t) = 0`.

    PROCEDURE Sub(t: T; start, length: CARDINAL): T;

Return a subsequence 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 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;

A text containing the single character `ch`.

    PROCEDURE FromChars(READONLY a: ARRAY OF CHAR): T;

A text containing the characters of `a`.

    PROCEDURE Hash(t: T): INTEGER;

Return a hash function of the contents of `t`.

    END Text.

    Last modified on Wed Apr  3 09:43:27 PST 1996 by heydon
         modified on Thu Jun  1 08:12:38 PDT 1995 by kalsow