CompareText("'Text1'", "'Text2'", ' CaseSensitive=1*')

Comment: The original name of this function was TextCompare. It was later renamed as CompareText. For compatibility reasons, the TextCompare function can still be used. The arguments are identical.

Arguments

'Text1'

Specification of the first comparison text

'Text2'

Specification of the second comparison text

'CaseSensitive*'

Optional parameter (default = 1) for determining whether a case sensitive comparison (consideration of upper and lower case) should be made

'CaseSensitive' 0

Take upper and lower case into account

'CaseSensitive' = 0

Ignore upper and lower case

Parameters ending with * are only evaluated once at the start of the acquisition.

Description

This function compares 2 texts alphabetically. This means that the characters of the 2 strings are compared individually starting with the left character. The function uses the current culture setting (Windows) to obtain culture-specific information such as spelling and alphabetical order. The comparison does not consider multi-digit values, word meaning or the length of the string. Blanks are taken into account in the comparison. With the optional parameter 'CaseSensitive=1', it can be determined whether upper and lower case should be considered (=1 or not specified), or not (<>1).

Dynamic text can be used by selecting a text signal. A text signal is set in square brackets []. It is also possible to enter constant text by just typing the text between the double quotes.

The function returns an analog value as the result.

Results

-1

if the characters of the first text appear in the alphabet before the characters of the second text.

0

if the two texts are equal

1

if the characters of the first text appear in the alphabet after the characters of the second text.

Example

The following table shows a couple of examples:

Text1

Text2

Result

Comment

CompareText ("Text1","Text2",0)

CompareText ("Text1","Text2",1)

1234 abcd

1234 abcd

0

0

1 = 2

1234 abcd

1234 bcde

-1

-1

Text1 < Text2

“a” comes before “b”

1234 Abcd

1234 abcd

0

1

Text1 = Text2 (not case sensitive)

Text1 > Text2 (case sensitive)

“A” comes after “a”

12340 abcd

1234 ˽ abcd

1

1

Text1 > Text2

"0" comes after " ˽"

1234 0abcd

1234 abcd

-1

-1

Text1 < Text2

“0” comes before “a”

12034 abcd

1234 abcd

-1

-1

Text1 < Text2

“0” comes before “3”

1234 abcd

1y34 abcd

-1

-1

Text1 < Text2

“2” comes before “y”

1z34 abcd

1Y34 abcd

1

1

Text1 > Text2

“z” comes after “Y”