MODULE Text; /* A template for the Text interface to be read in Button or Public view only. */ (* The built-in Juno Text module. A Juno text string is a zero-based sequence of characters. *) (* The variables "t", "u", and "tu" are texts; "i", "n", and "ch" are integers; and "r" is an arbitrary number. *) PROC tu := Cat(t, u) IS SKIP END; (* Returns the concatenation of "t" and "u". *) PROC n := Length(t) IS SKIP END; (* Returns the number of characters in "t". *) PROC u := Sub(t, i, n) IS SKIP END; (* Returns a subsequence of "t" starting at character "i" of length at most "n". The result is empty if "i >= Length(t)" or if "n = 0"; otherwise, it ranges from "i" to "MIN(i+n, Length(t)-1)". *) PROC ch := GetChar(t, n) IS SKIP END; (* Returns the integer code of character "n" of "t". It is a checked run-time error if "n < 0" or "n >= Length(t)". *) PROC t := FromChar(ch) IS SKIP END; (* Returns a string of length one containing the character with code "ch". It is a checked run-time error if "ch < 0" or "ch > 255". *) PROC t := FromNum(r, n) IS SKIP END; (* Returns the unparsing of the number "r" to "n" digits of precision. *) PROC i := FindChar(t, ch) IS SKIP END; (* Returns the index of first occurrence of the character "ch" in the text "t", or -1 if "ch" does not occur in "t". It is a checked run-time error if "ch < 0" or "ch > 255". *) PROC i := FindCharR(t, ch) IS SKIP END; (* Returns the index of last occurrence of the character "ch" in the text "t", or -1 if "ch" does not occur in "t". It is a checked run-time error if "ch < 0" or "ch > 255". *)