Promotic

StringCmp - method of the Pm object

Description:
Returns a result of a comparison of the two strings.
Syntax:
Long StringCmp(String sString1, String sString2, [String sParams])
Parameters:
sString1(String) First string to be compared.
sString2(String) Second string to be compared.
sParams[optional] (String) Additional parameters comparison. Entries are in the KeyVal format, for example mode:begin;ic:0;
mode:s;
mode:full; (default) - The two strings are compared for equality. If the strings length is different, then these cannot be equal.
mode:begin; - The beginning portion of the first string is compared with the whole second string. It means that the sString1 begins with the sString2.
mode:in; - It is detected whether the entire second string is contained inside the first string.
mode:system; - It compares whether the first string is less/equal/more than the second string. The strings are compared systematically. Application language settings are not taken into account, i.e. the result of the comparison will be the same in all application languages. This function is mainly used for sorting.
mode:locale; - It compares whether the first string is less/equal/more than the second string. Strings are compared locally. Application language settings are taken into account, i.e. the result of the comparison may be different in different application languages. This function is mainly used for sorting.
ic:n; - (IgnoreCase)
ic:0; (default) - case sensitive text
ic:1; - case insensitive text
Return values:
- for mode:full; or mode:begin;
0 - sString1 is not equal to sString2
1 - sString1 is equal to sString2
- for mode:in;
0 - sString1 does not contain sString2
1 - sString1 contains sString2
- for mode:system; or mode:locale;
-1 - sString1 is less than sString2
0 - sString1 is equal to sString2
1 - sString1 is more than sString2
Note:
This method is functional also in Macro expression $.expr and in the onDraw event of the PmgCanvas object.
This method is also functional in Web panels.
Example:
JavaScriptVBScriptSelect and copy to clipboard

var nRes = Pm.StringCmp("Windows 10", "Windows 10");   // nRes contains 1
nRes = Pm.StringCmp("Windows 10", "Windows");   // nRes contains 0
nRes = Pm.StringCmp("Windows 10", "Windows", "mode:begin;");   // nRes contains 1
nRes = Pm.StringCmp("WINDOWS 10", "Windows", "mode:begin;");   // nRes contains 0
nRes = Pm.StringCmp("WINDOWS 10", "Windows", "mode:begin;ic:1;");   // nRes contains 1
nRes = Pm.StringCmp("Windows 10", "10", "mode:in;");   // nRes contains 1

History:
Pm9.00.22: New option mode:in; allowing to detect whether the first string contains the second string.
Pm9.00.18: New option mode:system; and mode:locale; allowing to compare strings into less/equal/more systematically or locally.
Pm8.02.06: Created
PROMOTIC 9.0.23 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
Navigation:
 
- Pm
 
- Abs
- Cos
- E
- Exp
- LN2
- PI
- Pow
- Sin
- StringCmp
 
 
- Tan
© MICROSYS, spol. s r. o.