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


StringOrder

The StringOrder function compares two Pascal strings, taking into account the script system 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 StringOrder (aStr, bStr: Str255;
                      aScript, bScript: ScriptCode;
                      aLang, bLang: LangCode): Integer;
aStr
One of the Pascal strings to be compared.
bStr
The other Pascal string to be compared.
aScript
The script code for the first string.
bScript
The script code for the second string.
aLang
The language code for the first string.
bLang
The language code for the second string.
DESCRIPTION
StringOrder 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.

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

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

At this point, StringOrder 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 StringOrder function is primarily used to insert Pascal 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 CompareString function, described on page 5-62, to sort strings within a script or language group.

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


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996