Important: The information in this document is obsolete and should not be used for new development.
TruncString
TheTruncString
function ensures that a Pascal string fits into the specified pixel width, by truncating the string as necessary. This function makes use of the current script and font.
FUNCTION TruncString (width: Integer; VAR theString: Str255; truncWhere: TruncCode): Integer;
width
- The number of pixels in which the string must be displayed in the current script and font.
theString
- The Pascal string to be displayed. On output, contains a version of the string that has been truncated (if necessary) to fit in the number of pixels specified by
width
.truncWhere
- A constant that indicates where the string should be truncated. You must set this parameter to one of the constants
truncEnd
ortruncMiddle
.DESCRIPTION
TheTruncString
function ensures that a Pascal string fits into the pixel width specified by thewidth
parameter by modifying the string, if necessary, through truncation.TruncString
uses the font script to determine how to perform truncation. If truncation occurs,TruncString
inserts a truncation indicator, which is the ellipsis (...) in the Roman script system. You can specify which token to use for indicating truncation as thetokenEllipsis
token type in the untoken table of a tokens ('itl4'
) resource.The
truncWhere
parameter specifies where truncation is performed. If you supply thetruncEnd
value, characters are truncated off the end of the string. If you supply thetruncMiddle
value, characters are truncated from the middle of the string; this is useful when displaying pathnames.The
TruncString
function returns a result code that indicates whether the string
was truncated.SPECIAL CONSIDERATIONS
TruncString
may move memory; your application should not call this function at interrupt time.ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for theTruncString
function are
Trap macro Selector _ScriptUtil $8208 FFE0 RESULT CODES
Truncated 1 Truncation performed NotTruncated 0 No truncation necessary TruncErr -1 Truncation necessary, but cannot be performed within the specified width resNotFound -192 Cannot get the correct 'itl4'
resource or resource is not in current formatSEE ALSO
To determine the width of a string in the current font and script, use the QuickDrawStringWidth
function, which is described in the chapter "QuickDraw Text" in this book.