TruncString
short width ; specified pixel width for the text string
Str255 theString ; text string TruncCode truncWhere ; position in the text string to perform truncation
returns a short specifying the new string length
specified width by truncating the string, if necessary, in a manner dependent
on the font script.
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 string truncation function 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
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.