ReplaceText
The ReplaceText function searches text, replacing all instances of a string in that text with another string. ReplaceText searches on a character-by-character basis (as opposed to byte-by-byte), so it works properly for all script systems.
FUNCTION ReplaceText (baseText, substitutionText: Handle;
key: Str15): Integer;
baseText
- A handle to the string in which
ReplaceText is to substitute text.
substitutionText
- A handle to the string that
ReplaceText uses as substitute text.
key
- A Pascal string of less than 16 bytes that
ReplaceText searches for.
DESCRIPTION
ReplaceText searches the text specified by the baseText parameter for instances of the string in the key parameter and replaces each instance with the text specified by the substitutionText parameter. ReplaceText searches on a character-by-character basis. It recognizes 2-byte characters in script systems that contain them and advances the search appropriately after encountering a 2-byte character.
ReplaceText returns an integer value. If the returned value is positive, it indicates the number of substitutions performed; if it is negative, it indicates an error. The constant noErr is returned if there was no error and no substitutions were performed.
SPECIAL CONSIDERATIONS
ReplaceText may move memory; your application should not call this function at interrupt time.
ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for the ReplaceText function are
| Trap macro | Selector |
| _ScriptUtil | $820C FFDC |
RESULT CODES
| nilHandleErr | 109 | GetHandleSize fails on baseText or substitutionText |
| memFullErr | 108 | SetHandleSize fails on baseText |
| memWZErr | -111 | GetHandleSize fails on baseText or substitutionText |