Platforms to show: All Mac Windows Linux Cross-Platform

NSStringCompareMBS(s as string, t as string, options as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
global method Cocoa MBS Main Plugin 8.6 ✅ Yes ❌ No ❌ No ✅ Yes All
Compares two things using the Cocoa string functions.
Example
// constants for the function:
const NSCaseInsensitiveSearch = 1
const NSLiteralSearch = 2
const NSBackwardsSearch = 4
const NSAnchoredSearch = 8
const NSNumericSearch = 64
const NSDiacriticInsensitiveSearch = 128
const NSWidthInsensitiveSearch = 256
const NSForcedOrderingSearch = 512

const NSOrderedAscending = -1
const NSOrderedSame = 0
const NSOrderedDescending = 1

if NSStringCompareMBS("Hello","hello", NSCaseInsensitiveSearch)=0 then
msgbox "equal (correct)"
else
msgbox "not equal"
end if

if NSStringCompareMBS("Hello","hello", 0)=0 then
msgbox "equal"
else
msgbox "not equal (correct)"
end if

if NSStringCompareMBS("Hello","Hellö", NSDiacriticInsensitiveSearch)=0 then
msgbox "equal (correct)"
else
msgbox "not equal"
end if

Following constants can be used for the compare:

NSCaseInsensitiveSearch1Case Insensitive
NSLiteralSearch2Exact character-by-character equivalence
NSBackwardsSearch4Search from end of source string
NSAnchoredSearch8Search is limited to start (or end, if NSBackwardsSearch) of source string
NSNumericSearch64Added in 10.2; Numbers within strings are compared using numeric value, that is, Foo2.txt < Foo7.txt < Foo25.txt; only applies to compare methods, not find
NSDiacriticInsensitiveSearch128If specified, ignores diacritics (o-umlaut = o)
NSWidthInsensitiveSearch256If specified, ignores width differences ('a' = UFF41)
NSForcedOrderingSearch512If specified, comparisons are forced to return either NSOrderedAscending or NSOrderedDescending if the strings are equivalent but not strictly equal, for stability when sorting (e.g. "aaa" > "AAA" with NSCaseInsensitiveSearch specified)

The constants NSDiacriticInsensitiveSearch, NSWidthInsensitiveSearch and NSForcedOrderingSearch are only for Mac OS X 10.5 and newer versions.

Returns value constants:
NSOrderedAscending-1
NSOrderedSame0
NSOrderedDescending1

Some examples using this global method:

Blog Entries

The items on this page are in the following plugins: MBS Main Plugin.


The biggest plugin in space...