75 lines
1.9 KiB
Plaintext
75 lines
1.9 KiB
Plaintext
void local fn StringComparison
|
|
CFStringRef s1, s2
|
|
NSComparisonResult result
|
|
|
|
window 1, @"String Comparison"
|
|
|
|
print @"• equal - case sensitive •"
|
|
s1 = @"alpha" : s2 = @"alpha"
|
|
if ( fn StringIsEqual( s1, s2 ) )
|
|
printf @"\"%@\" is equal to \"%@\"",s1,s2
|
|
end if
|
|
|
|
result = fn StringCompare( s1, s2 )
|
|
if ( result == NSOrderedSame )
|
|
printf @"\"%@\" is equal to \"%@\"",s1,s2
|
|
end if
|
|
|
|
select ( s1 )
|
|
case s2
|
|
printf @"\"%@\" is equal to \"%@\"",s1,s2
|
|
case else
|
|
printf @"\"%@\" is not equal to \"%@\"",s1,s2
|
|
end select
|
|
|
|
print @"\n• not equal - case sensitive •"
|
|
s2 = @"bravo"
|
|
if ( fn StringIsEqual( s1, s2 ) == NO )
|
|
printf @"\"%@\" is not equal to \"%@\"",s1,s2
|
|
end if
|
|
|
|
result = fn StringCompare( s1, s2 )
|
|
if ( result != NSOrderedSame )
|
|
printf @"\"%@\" is not equal to \"%@\"",s1,s2
|
|
end if
|
|
|
|
select ( s1 )
|
|
case s2
|
|
printf @"\"%@\" is equal to \"%@\"",s1,s2
|
|
case else
|
|
printf @"\"%@\" is not equal to \"%@\"",s1,s2
|
|
end select
|
|
|
|
print @"\n• ordered before - case sensitive •"
|
|
result = fn StringCompare( s1, s2 )
|
|
if ( result == NSOrderedAscending )
|
|
printf @"\"%@\" is ordered before \"%@\"",s1,s2
|
|
end if
|
|
|
|
print @"\n• ordered after - case sensitive •"
|
|
result = fn StringCompare( s2, s1 )
|
|
if ( result == NSOrderedDescending )
|
|
printf @"\"%@\" is ordered after \"%@\"",s2,s1
|
|
end if
|
|
|
|
print @"\n• equal - case insensitive •"
|
|
s2 = @"AlPhA"
|
|
result = fn StringCaseInsensitiveCompare( s1, s2 )
|
|
if ( result == NSOrderedSame )
|
|
printf @"\"%@\" is equal to \"%@\"",s1,s2
|
|
end if
|
|
|
|
result = fn StringCompareWithOptions( s1, s2, NSCaseInsensitiveSearch )
|
|
if ( result == NSOrderedSame )
|
|
printf @"\"%@\" is equal to \"%@\"",s1,s2
|
|
end if
|
|
|
|
if ( fn StringIsEqual( lcase(s1), lcase(s2) ) )
|
|
printf @"\"%@\" is equal to \"%@\"",s1,s2
|
|
end if
|
|
end fn
|
|
|
|
fn StringComparison
|
|
|
|
HandleEvents
|