Examples: Option Compare statement
Example 1
The following example is specific to Windows™. In this example, the first call to function StrCompare uses the default (case-sensitive) setting without the optional argument that specifies a comparison method. In case-insensitive comparison, "A" equals "a", so StrCompare returns FALSE (0).
The second call to the function StrCompare specifies case-sensitive comparison in the country/language collation order, overriding the default established by Option Compare NoCase. In this comparison, "A" occurs earlier in the sort order than "a", so StrCompare returns TRUE (-1).
' The following results are for LotusScript in English,
' running on Windows 3.1.
Option Compare NoCase
' No method specified in StrCompare; use NoCase.
Print StrCompare("A", "a") ' Output: 0, these two strings are equal.
' Use case-sensitive comparison
' (in country/language collation order).
Print StrCompare("A", "a", 0) ' Output: 1, string1 greater than
' string 2. Strings are not equal.
Example 2
In this example, no Option Compare statement appears in the module, so the list tags "a" and "A" are different tags, because case-sensitive comparison in the country/language collation order is the default. Thus, the assignments to Loft("a") and Loft("A") refer to two different list elements. Within the ForAll statement, the ListTag function retrieves a list tag; and the Print statement prints it on a separate line.
Dim loft List As Integer
loft%("a") = 2
loft%("A") = 17
ForAll i In loft%
Print ListTag(i) ' Output: "a" and "A"
End ForAll
Example 3
In this example, the Option Compare NoCase statement specifies case-insensitive comparison in the country or region/language collation order as the default method for string comparison, so the list tags "a" and "A" are the same tag. Thus, the assignments to loft("a") and loft("A") refer to the same list element. There is only one list tag for the ListTag function to retrieve and print.
Option Compare NoCase
Dim loft List As Integer
loft%("a") = 2
loft%("A") = 17
ForAll i In loft%
Print ListTag(i) ' Output: "A"
End ForAll
Example 4
In this example, the Option Compare Binary statement specifies bit-wise (platform sort-order, case-sensitive) comparison as the default method for string comparison, so the list tags "a" and "A" are different tags. Thus, the assignments to loft("a") and loft("A") refer to different list elements.
Option Compare Binary
Dim loft List As Integer
loft%("a") = 2
loft%("A") = 17
ForAll i In loft%
Print ListTag(i) ' Output: "a" and "A"
End ForAll