Occurrences
Moderator: Klaus
Occurrences
I would love a built in function that counts the number of occurrences of some string in a variable/field of text
Re: Occurrences
Good idea! But it only takes 3 lines of code to do it now. (Well, it can be done in 1 line, but that method might run just a bit slower.)
Best wishes,
Curry Kenworthy
LiveCode Development, Training & Consulting
http://livecodeconsulting.com/
WordLib: Conquer MS Word & OpenOffice
SpreadLib: "Excel-lent" spreadsheet import/export
http://livecodeaddons.com/
Curry Kenworthy
LiveCode Development, Training & Consulting
http://livecodeconsulting.com/
WordLib: Conquer MS Word & OpenOffice
SpreadLib: "Excel-lent" spreadsheet import/export
http://livecodeaddons.com/
Re: Occurrences
Kessingb,
If i understand what you want, you can try this script
regards
Jean-Marc
If i understand what you want, you can try this script
Code: Select all
function NbOccurInTexte psearch,pCont
put 0 into rNbOccurInTexte
put 0 into tCharsToSkip
repeat
put offset(psearch, pCont, tCharsToSkip) into UneOcc
if UneOcc = 0 then exit repeat
add UneOcc to tCharsToSkip
add 1 to rNbOccurInTexte
end repeat
return rNbOccurInTexte
end NbOccurInTexte
Jean-Marc
https://alternatic.ch
Re: Occurrences
Curry.
I use a short function very similar to the one offered by jmburnod. It gives me the number and locations of a string in a pile of data.
Three lines (or one long one?) sounds like there is a native "allOccurrances" sort of gadget in Rev.
Is there?
Craig Newman
I use a short function very similar to the one offered by jmburnod. It gives me the number and locations of a string in a pile of data.
Three lines (or one long one?) sounds like there is a native "allOccurrances" sort of gadget in Rev.
Is there?
Craig Newman