<> <> <> <> <> DIRECTORY Environment USING [ bitsPerCharacter, charsPerPage, charsPerWord, logCharsPerPage]; String: DEFINITIONS = BEGIN bitsPerCharacter: CARDINAL = Environment.bitsPerCharacter; charsPerPage: CARDINAL = Environment.charsPerPage; charsPerWord: CARDINAL = Environment.charsPerWord; logCharsPerPage: CARDINAL = Environment.logCharsPerPage; SubStringDescriptor: TYPE = RECORD [base: LONG STRING, offset, length: CARDINAL]; SubString: TYPE = LONG POINTER TO SubStringDescriptor; Overflow: SIGNAL; InvalidNumber: SIGNAL; StringBoundsFault: SIGNAL [s: LONG STRING] RETURNS [ns: LONG STRING]; Length: PROCEDURE [s: LONG STRING] RETURNS [CARDINAL] = INLINE { RETURN[IF s = NIL THEN 0 ELSE s.length]}; Empty: PROCEDURE [s: LONG STRING] RETURNS [BOOLEAN] = INLINE { RETURN[s = NIL OR s.length = 0]}; WordsForString: PROCEDURE [nchars: CARDINAL] RETURNS [CARDINAL] = INLINE { RETURN[SIZE[StringBody[nchars]]]}; AppendChar: PROCEDURE [s: LONG STRING, c: CHARACTER]; AppendString: PROCEDURE [to: LONG STRING, from: LONG STRING]; Copy: PROCEDURE [to, from: LONG STRING]; Equal, Equivalent: PROCEDURE [s1, s2: LONG STRING] RETURNS [BOOLEAN]; Compare: PROCEDURE [s1, s2: LONG STRING, ignoreCase: BOOLEAN _ TRUE] RETURNS [INTEGER]; -- -1 => less, 0 => equal, 1 => greater AppendSubString: PROCEDURE [to: LONG STRING, from: SubString]; EqualSubString, EquivalentSubString: PROCEDURE [s1, s2: SubString] RETURNS [BOOLEAN]; DeleteSubString: PROCEDURE [s: SubString]; UpperCase, LowerCase: PROCEDURE [c: CHARACTER] RETURNS [CHARACTER]; <> StringToNumber: PROCEDURE [s: LONG STRING, radix: CARDINAL _ 10] RETURNS [UNSPECIFIED]; StringToDecimal: PROCEDURE [s: LONG STRING] RETURNS [INTEGER] = INLINE BEGIN RETURN[StringToNumber[s, 10]] END; StringToOctal: PROCEDURE [s: LONG STRING] RETURNS [UNSPECIFIED] = INLINE BEGIN RETURN[StringToNumber[s, 8]]; END; StringToLongNumber: PROCEDURE [s: LONG STRING, radix: CARDINAL _ 10] RETURNS [LONG UNSPECIFIED]; AppendNumber: PROCEDURE [s: LONG STRING, n: UNSPECIFIED, radix: CARDINAL _ 10]; AppendDecimal: PROCEDURE [s: LONG STRING, n: INTEGER]; AppendOctal: PROCEDURE [s: LONG STRING, n: UNSPECIFIED]; AppendLongNumber: PROCEDURE [ s: LONG STRING, n: LONG UNSPECIFIED, radix: CARDINAL _ 10]; AppendLongDecimal: PROCEDURE [s: LONG STRING, n: LONG INTEGER]; <> MakeString: PROCEDURE [z: UNCOUNTED ZONE, maxlength: CARDINAL] RETURNS [LONG STRING] = INLINE {RETURN[z.NEW[StringBody [maxlength]]]}; MakeMDSString: PROCEDURE [z: MDSZone, maxlength: CARDINAL] RETURNS [STRING] = INLINE {RETURN[z.NEW[StringBody [maxlength]]]}; FreeString: PROCEDURE [z: UNCOUNTED ZONE, s: LONG STRING] = INLINE {z.FREE[@s]}; <> FreeMDSString: PROCEDURE [z: MDSZone, s: STRING] = INLINE {z.FREE[@s]}; -- note this sets local s to NIL AppendCharAndGrow: PROC [ to: LONG POINTER TO LONG STRING, c: CHARACTER, z: UNCOUNTED ZONE]; AppendExtensionIfNeeded: PROC [ to: LONG POINTER TO LONG STRING, extension: LONG STRING, z: UNCOUNTED ZONE] RETURNS [BOOLEAN]; AppendStringAndGrow: PROC [ to: LONG POINTER TO LONG STRING, from: LONG STRING, z: UNCOUNTED ZONE, extra: CARDINAL _ 0]; Replace: PROC [ to: LONG POINTER TO LONG STRING, from: LONG STRING, z: UNCOUNTED ZONE]; CopyToNewString: PROCEDURE [ s: LONG STRING, z: UNCOUNTED ZONE, longer: CARDINAL _ 0] RETURNS [newS: LONG STRING]; ExpandString: PROCEDURE [ s: LONG POINTER TO LONG STRING, longer: CARDINAL, z: UNCOUNTED ZONE]; <> StringLength: PROCEDURE [s: LONG STRING] RETURNS [CARDINAL] = INLINE { RETURN[Length[s]]}; EmptyString: PROCEDURE [s: LONG STRING] RETURNS [BOOLEAN] = INLINE { RETURN[Empty[s]]}; EqualString, EqualStrings: PROCEDURE [s1, s2: LONG STRING] RETURNS [BOOLEAN] = INLINE {RETURN[Equal[s1, s2]]}; EquivalentString, EquivalentStrings: PROCEDURE [s1, s2: LONG STRING] RETURNS [BOOLEAN] = INLINE {RETURN[Equivalent[s1, s2]]}; CompareStrings: PROCEDURE [s1, s2: LONG STRING, ignoreCase: BOOLEAN _ TRUE] RETURNS [INTEGER] = INLINE {RETURN[Compare[s1, s2, ignoreCase]]}; EqualSubStrings: PROCEDURE [s1, s2: SubString] RETURNS [BOOLEAN] = INLINE { RETURN[EqualSubString[s1, s2]]}; EquivalentSubStrings: PROCEDURE [s1, s2: SubString] RETURNS [BOOLEAN] = INLINE { RETURN[EquivalentSubString[s1, s2]]}; END.