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 / Determining Sorting Order for Strings in Different Languages


TextOrder

The TextOrder function compares two text strings, taking into account the script and language for each of the strings. It takes both primary and secondary sorting orders into consideration and returns a value that indicates whether the first string is less than, equal to, or greater than the second string.

FUNCTION TextOrder (aPtr, bPtr: Ptr; aLen, bLen: Integer; 
                    aScript, bScript: ScriptCode;
                    aLang, bLang: LangCode): Integer;
aPtr
A pointer to the first character of the first text string.
bPtr
A pointer to the first character of the second text string.
aLen
The number of bytes in the first text string.
bLen
The number of bytes in the second text string.
aScript
The script code for the first text string.
bScript
The script code for the second text string.
aLang
The language code for the first text string.
bLang
The language code for the second text string.
DESCRIPTION
TextOrder returns -1 if the first string is less than the second string, 0 if the first string is equal to the second string, and 1 if the first string is greater than the second string. The ordering of script and language codes, which is based on information in the script-sorting resource, is considered in determining the relationship of the two strings.

Script code values and explicit language code values are listed in the chapter "Script Manager"; implicit language codes are listed in Table 5-13 on page 5-55 of this chapter. Most applications specify the language code scriptCurLang for both the aLang and bLang values.

TextOrder first calls ScriptOrder; if the result of ScriptOrder is not 0 (that is, if the strings use different scripts), TextOrder returns the same result.

TextOrder next calls LanguageOrder; if the result of LanguageOrder is not 0 (that is, if the strings use different languages), TextOrder returns the same result.

At this point, TextOrder has two strings that are in the same script and language, so it compares them by using the sorting rules for that script and language, applying both the primary and secondary sorting orders. If that script is not installed and enabled (as described in the chapter "Script Manager" in this book), it uses the sorting rules specified by the system script or the font script, depending on the state of the international resources selection flag. See the section "Obtaining Resource Information," beginning on page 5-4.

The TextOrder function is primarily used to insert text strings in a sorted list; for sorting, rather than using this function, it may be faster to sort first by script and language by using the ScriptOrder and LanguageOrder functions, and then to call the CompareText function, described on page 5-63, to sort strings within a script or language group.

SPECIAL CONSIDERATIONS
TextOrder may move memory; your application should not call this function at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for the TextOrder function are
Trap macroSelector
_Pack6$0022


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996