PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | French EN
  • Equivalence between StringCompare and comparison operators
  • Comparing numeric values
  • Characters taken into account for punctuation and spaces
  • StringCompare and UNICODE
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Compares two strings character by character:
  • according to the sequence of ASCII characters.
  • according to the alphabetical order.
Versions 15 and later
Android This function is now available for Android applications.
New in version 15
Android This function is now available for Android applications.
Android This function is now available for Android applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
New in version 18
Android Widget This function is now available in Android Widget mode.
Android Widget This function is now available in Android Widget mode.
Versions 21 and later
Apple Watch This function is now available in Apple Watch mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Apple Watch This function is now available in Apple Watch mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Apple Watch This function is now available in Apple Watch mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Example
MyString1 is string = "Developing is fantastic"
MyString2 is string = "Developing is simple"
ResultCompare is int = StringCompare(MyString1, MyString2)
// ResultCompare = -1: the character 'f' comes before the character 's'
Syntax
<Result> = StringCompare(<First string> , <Second string> [, <Options>])
<Result>: Integer
  • 0 if the character strings are equal.
  • -1 if the characters in <First string> come before the characters in <Second string> according to the ASCII order or to the lexicographic order.
  • 1 if the characters in <First string> come after the characters in <Second string> according to the ASCII order or to the lexicographic order.
<First string>: Character string (with quotes)
Character string to compare.
<Second string>: Character string (with quotes)
Character string to compare.
<Options>: Optional constant (or combination of constants)
Comparison options:
ccNormal
(default value)
Standard comparison, similar to the '=' operator.
ccLexicographicOrderCompares strings in lexicographical order (for example, 'é' is between 'e' and 'f').
WEBDEV - Browser codePHP This constant is not available.
ccRespectNumericCompares strings taking into account the numeric values within the strings (in this case, "10" comes after "9").
ccIgnoreAccentCompares strings ignoring accented characters.
WEBDEV - Browser code This constant is not available.
ccIgnoreCaseCompares strings ignoring the case (uppercase/lowercase characters).
ccIgnoreSpaceCompares strings ignoring spaces before and after the strings.
Versions 20 and later
ccIgnoreInsideSpace
New in version 20
ccIgnoreInsideSpace
ccIgnoreInsideSpace
Compares strings ignoring spaces within the strings.
WEBDEV - Browser codeAndroidAndroid Widget JavaPHP This constant is not available.
ccIgnorePunctuationAndSpaceCompares strings ignoring punctuation and spaces (see Notes for more details).
WEBDEV - Browser code This constant is not available.
Remarks

Equivalence between StringCompare and comparison operators

  • = operator:
    The = operator is equivalent to the following code: StringCompare(<String1>, <String2>, ccNormal)
  • ~= operator:
    The ~= operator is equivalent to the following code: StringCompare(<String1>, <String2>, ccIgnoreCasse, + ccIgnoreAccent + ccIgnoreSpace)
    WEBDEV - Browser code This syntax is not available.
  • ~~ operator:
    The ~~ operator is equivalent to the following code: StringCompare(<String1>, <String2>, ccIgnoreCasse + ccIgnoreAccent + ccIgnorePonctuationAndSpace)
    WEBDEV - Browser code This syntax is not available.
  • <, >, <= and >= operators:
    These operators are equivalent to the following code: StringCompare(<String1>, <String2>, ccLexicographicOrder)
    WEBDEV - Browser code This syntax is not available.
See the Comparison operators for more details.
Reports and QueriesWindowsLinuxAndroidAndroid Widget Universal Windows 10 AppWindows MobileJavaAjaxUser code (UMC)

Comparing numeric values

The ccRespectNumeric constant sorts by taking into account the numeric value represented by digits and not just the alphabetical order of the numbers.
Without the ccRespectNumeric constant, the strings below will be sorted in the following order: "string1", "string10", "string2"
With the ccRespectNumeric constant, the same strings will be sorted in this order: "string1", "string2", "string10"
Examples of comparison performed with and without the ccRespectNumeric constant:
Sorting strings containing digits without the ccRespectNumeric constantSorting strings containing digits with the ccRespectNumeric constant
000
000
001001
00901
011
010009
0909
19
10010
1110
911
Sorting strings containing digits without the ccRespectNumeric constantSorting strings containing digits with the ccRespectNumeric constant
10.00Aa7.00Aa
10.01Gh7.01Ba
10.50Ag7.01Dfe
11.00Aa7.50Fg
7.00Aa7.51Tga
7.01Ba8.00Aa
7.01Dfe8.01Gjk
7.50Fg8.01Ty
7.51Tga8.50Ze
8.00Aa9.00Aa
8.01Gjk9.80Er
8.01Ty9.99Zaaa
8.50Ze10.00Aa
9.00Aa10.01Gh
9.80Er10.50Ag
9.99Zaaa11.00Aa

Characters taken into account for punctuation and spaces

The characters taken into account for punctuation and spaces are provided by the system. To get the list of these characters, write the following WLanguage code:
s is string
FOR i = 0 TO 255
IF Charact(i) <> StringFormat(Charact(i), ccIgnorePunctuationAndSpace) THEN
 s += Charact(i)
END
END
Info(s)
ToClipboard(s)
Reports and QueriesWindowsLinuxAndroidAndroid Widget Universal Windows 10 AppWindows MobileJavaPHPAjaxUser code (UMC)

StringCompare and UNICODE

You have the ability to use ANSI strings, Unicode strings and buffers in the different parameters of the function.
The following conversion rule is used for the Ansi systems (Windows or Linux):
  • If at least one of the strings is a buffer, all the strings are converted to buffers and the operation is performed with buffers.
  • If the first condition is not met and there is at least one Unicode string, all the strings are converted to Unicode and the operation is performed in Unicode (the conversion is performed with the current character set, if necessary).
  • Otherwise, the operation is performed in Ansi.
The following conversion rule is used for the Unicode systems (Windows CE):
  • If at least one of the strings is a buffer, all the strings are converted to buffers and the operation is performed with buffers.
  • Otherwise, the operation is performed in Unicode.
See Managing UNICODE for more details.
Reminder: The linguistic parameters used are defined during the call to ChangeCharset.
Business / UI classification : Neutral code
Component : wd260vm.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment