CompareText('Text1','Text2','CaseSensitive'=TRUE,'NumericalSort'=FALSE)
Arguments
|
'Text1/2' |
Strings to compare |
|
'CaseSensitive' |
Optional parameter to enable case sensitivity during comparison |
|
'NumericalSort' |
Optional parameter to specify whether digits are compared individually or whether combinations of digits are compared as numbers. |
Description
With this function, you can compare the text information lexicographically. The function works with contents of text signals as well as with plain text that you can enter directly in the signal definition using quotation marks.
Comparison and results:
-
Result -1: The first text comes before the second text lexicographically.
-
Result 0: Both texts contain the same information.
-
Result +1: The first text comes after the second text lexicographically.
Example
The following table shows the general functionality and the impact of the 'CaseSensitive' parameter:
|
Text1 |
Text2 |
Result for |
Comment |
|
|---|---|---|---|---|
|
CompareText ("Text1","Text2",0) |
CompareText ("Text1","Text2",1) |
|||
|
1234 abcd |
1234 abcd |
0 |
0 |
Text1 = Text2 |
|
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 before "a" |
|
12340 abcd |
1234 abcd |
1 |
1 |
Text1 > Text2 "0" comes after " " (space) |
|
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" |
The following table shows the impact of the 'NumericalSort' parameter:
|
Text1 |
Text2 |
Result for |
|
|---|---|---|---|
|
CompareText ("Text1","Text2",0,0) |
CompareText ("Text1","Text2",0,1) |
||
|
12034 abcd |
1234 abcd |
-1 Text1 < Text2 "0" comes before "3" |
1 Text1 > Text2 "12034" comes after "1234" |