PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Search in an array: managing the ambiguities
  • StringCount function 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
Calculates:
  • the number of occurrences of a specific character string (by respecting the search criteria) in another character string.
  • the number of occurrences of a set of strings found in an array.
    Universal Windows 10 App This feature is not available in Windows Phone.
Versions 15 and later
Android This function is now available for the Android applications.
New in version 15
Android This function is now available for the Android applications.
Android This function is now available for the Android applications.
Versions 16 and later
Universal Windows 10 App This function is now available for the Windows Phone applications.
New in version 16
Universal Windows 10 App This function is now available for the Windows Phone applications.
Universal Windows 10 App This function is now available for the Windows Phone applications.
Versions 17 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for the iPhone/iPad applications.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
New in version 18
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps 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
Res = StringCount("anastasia", "a")         // Returns 4
Res = StringCount("toto titi tito", "to")   // Returns 3
Res = StringCount("toaster", "X")       // Returns 0
Res = StringCount("Le merle est dans le chêne", "le") // returns 2
Res = StringCount("Le merle est dans le chêne", "le", WholeWord) // returns 1
Res = StringCount("Le merle est dans le chêne", "le", IgnoreCase) // Returns 3
Res = StringCount("Le merle est dans le chêne", "le", IgnoreCase + WholeWord) // Returns 2
Res = StringCount("anastasia", ["a","s"])         // Returns 6
Syntax

Number of occurrences of a character string Hide the details

<Result> = StringCount(<Source String> , <String to Find> [, <Options>])
<Result>: Integer
  • Number of occurrences,
  • 0 if no occurrence exists or if <String To Find> corresponds to an an empty string ("").
<Source String>: Character string (with quotes)
Text into which the occurrences of <String to Find> must be sought.
<String to Find>: Character string (with quotes)
Text to find in <Source String>.
<Options>: Optional constant (or combination of constants)
Search options:
WholeWordSearches for a whole word, which means enclosed in punctuation characters (characters other than a letter or a digit) or in space characters.
WEBDEV - Browser code This constant is not available.
IgnoreCaseSearches while ignoring the case (uppercase/lowercase characters)
Versions 16 and later
PHP This syntax is now available for the PHP sites.
New in version 16
PHP This syntax is now available for the PHP sites.
PHP This syntax is now available for the PHP sites.

Number of occurrences of the character strings found in an array Hide the details

<Result> = StringCount(<Source String> , <Array of Strings to Find> [, <Options>])
<Result>: Integer
  • Number of occurrences,
  • 0 if there is no occurrences or if <Array of String to Find> contains empty strings ("").
<Source String>: Character string (with quotes)
Text into which the occurrences of <String to Find> must be sought.
<Array of Strings to Find>: Array
Name of the array containing the character strings that must be found in the <Source String>.
<Options>: Optional constant (or combination of constants)
Search options:
WholeWordSearches for a whole word, which means enclosed in punctuation characters (characters other than a letter or a digit) or in space characters.
WEBDEV - Browser code This constant is not available.
IgnoreCaseSearches while ignoring the case (uppercase/lowercase characters)
Remarks

Search in an array: managing the ambiguities

When the strings to find are sub-strings of other strings found in the array, the longest strings are taken into account.
Example: If the ["after", "afternoon", "afterward"] array of strings must be found in "Come this afternoon after the game", the first occurrence found will be "afternoon" (and not "after").

StringCount function and UNICODE

<Source String> and <String to Find> can both correspond to:
  • ANSI strings.
  • UNICODE strings.
  • buffers.
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):
  • It at least one of the strings is a buffer, all the strings are converted into buffers and the operation is performed with buffers,
  • otherwise, if at least one of the strings is in Unicode format, all the strings are converted into Unicode and the operation is performed in Unicode,
  • Otherwise, the operation is performed in Ansi.
The following conversion rule is used for the Unicode systems (Windows CE):
  • It at least one of the strings is a buffer, all the strings are converted into buffers and the operation is performed with buffers,
  • Otherwise, the operation is performed in Unicode.
See Managing the UNICODE format for more details.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230vm.dll
Windows Mobile wp230vm.dll
WEBDEV - Browser code WDJS.DLL
Java wd230java.jar
Linux wd230vm.so
Android wd230android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
Exemplo StringCount
Aula 1052 - WinDev String - 035 - StringCount


//Nessa aula vou mostrar como saber quantidade de uma determinada
//pesquisa


SAI_Quantos = StringCount(SAI_Texto,SAI_pesquisa)
//SAI_Quantos = StringCount("amarildo","a") // 2 A encontrado
SAI_Quantos = StringCount("anastasia", ["a","s"])
SAI_Quantos= StringCount(SAI_Texto,CR)

//Blog com Video e Exemplo

http://windevdesenvolvimento.blogspot.com.br/2017/01/aula-1052-windev-string-035-stringcount.html

https://www.youtube.com/watch?v=mt9djer3RXw

De matos
Feb. 01 2017
quantas linhas foram preenchidas em um controle RTF
//quantas linhas foram preenchidas em um controle RTF

_texto is string=RTFToText(EDT_RTF_Text)
EDT_QuantasLinhas= StringCount(_texto,CR)

//Blog com Video e Exemplo

http://windevdesenvolvimento.blogspot.com.br/2016/10/aula-949-windev-string-23-somar-quantas.html

https://www.youtube.com/watch?v=21ZWVdaNO58

De matos
Oct. 23 2016