TruncText
short TruncText( width, textPtr, length,truncWhere ); short width ; specified pixel width for the text string
Ptr textPtr ; a pointer to the text to be truncated short * length ; specifies the length of the text
TruncCode truncWhere ; position in the text string to perform truncatation
returns a short specifying the new string length
TruncText ensures that a string defined by a pointer and a byte length fits into the specified pixel width, by truncating the string as described in
Returns: an error code. It will be one of: Result codes
smNotTruncated (0) No truncation necessary
smTruncated (1) Truncation performed
smTruncErr (-1) General error (At present, this only occurs if
truncation is necessary, but the truncation
indicator alone is wider than the specified
width. If this error occurs, the length is set
to 0.)
resNotFound (-192) Cannot get the correct 'itl4' resource or
resource is not in current format
Notes: The text truncation functions ensure that a text string fits into the pixel
width specified by the width parameter and then truncates the string, when
necessary. These functions use the font script to determine how to perform
truncation. If truncation occurs, they also insert a truncation indicator
(such as an ellipsis in English).
The truncWhere parameter specifies whether truncation occurs at the end of the string or in the middle (the latter is useful for path names, for
example). Specify the constant smTruncEnd to truncate the string at the
end. Specify the constant smTruncMiddle to truncate the string in the
middle. The TruncText function defines the string by a pointer and byte length.If truncation occurs, the string length is updated to reflect the new
length. If general errors occur, the result code is smTruncErr and the
length is set to 0. In any case, the length never increases.
With System 7.0, a new token type, tokenEllipsis, has been defined; the
character from the untoken table in the 'itl4' resource. See
System Software for more information on the 'itl4' tables and related data
by the Script Manager itself, not by script systems. Both text truncation functions may move memory.