Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Text /
Chapter 5 - Text Utilities / Text Utilities Reference
Routines / Working With Word, Script, and Line Boundaries


FindWordBreaks

The FindWordBreaks procedure determines the beginning and ending boundaries of a word in a text string.

PROCEDURE FindWordBreaks(textPtr: Ptr; textLength: Integer;
                  offset: Integer; leadingEdge: Boolean; 
                  nbreaks: BreakTablePtr; 
                  VAR offsets: OffsetTable; script: ScriptCode);
textPtr
A pointer to the text string to be examined.
textLength
The number of bytes in the text string.
offset
A byte offset into the text. This parameter plus the leadingEdge parameter determine the position of the character at which to start
the search.
leadingEdge
A flag that specifies which character should be used to start the search. If leadingEdge is TRUE, the search starts with the character specified in the offset parameter; if it is FALSE, the search starts with the character previous to the offset.
nbreaks
A pointer to a word-break table of type NBreakTable or BreakTable.
If the value of this pointer is 0, the default word-break table of the script system specified by the script parameter is used. If the value of
this pointer is -1, the default line-break table of the specified script
system is used.
offsets
On output, the values in this table indicate the boundaries of the word that has been found.
script
The script code for the script system whose tables are used to determine where word boundaries occur.
DESCRIPTION
FindWordBreaks searches for a word in a text string. The textPtr and textLength parameters specify the text string that you want searched. The offset parameter and leadingEdge parameter together indicate where the search begins.

If leadingEdge is TRUE, the search starts at the character at the offset. If leadingEdge is FALSE, the search starts at the character preceding the offset position.

FindWordBreaks searches backward through the text string for one of the word boundaries and forward through the text string for its other boundary. It uses the definitions in the table specified by nbreaks to determine what constitutes the boundaries of a word. Each script system's word-break table is part of its string-manipulation ('itl2') resource. The format of the NBreakTable record is described in the appendix "International Resources" in this book.

FindWordBreaks returns its results in an OffsetTable record, the format of which is described in the section "The Offset Table Record" on page 5-44. FindWordBreaks uses only the first element of this three-element table. Each element is a pair of integers: offFirst and offSecond.

FindWordBreaks places the offset from the beginning of the text string to just before the leading edge of the character of the word that it finds in the offFirst field.

FindWordBreaks places the offset from the beginning of the text string to just after the trailing edge of the last character of the word that it finds in the offSecond field. For example, if the text "This is it" is passed with offset set to 0 and leadingEdge set to TRUE, then FindWordBreaks returns the offset pair (0,4).

If leadingEdge is TRUE and the value of offset is 0, then FindWordBreaks returns the offset pair (0,0). If leadingEdge is FALSE and the value of offset equals the value of textLength, then FindWordBreaks returns the offset pair with values (textLength, textLength).

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for the FindWordBreaks procedure are
Trap macroSelector
_ScriptUtil$C012 001A


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996