Re: Get number of occurrences of one string in another

2012-02-23 Thread Kay C Lan
On Fri, Feb 24, 2012 at 3:48 AM, Sumner, Walt wrote: > Here's a small speed increment, still no repeat loops except for 3 or 4 > hidden within Livecode. Counts "pp" as 3 "pp", not 5. > > I've had a look at this and generally don't agree that there are only 3 "pp" in "pp". I accept that in

Re: Get number of occurrences of one string in another

2012-02-23 Thread Bob Sneidar
Ohhh... sexier! Bob On Feb 23, 2012, at 10:10 AM, Ken Ray wrote: > > On Feb 22, 2012, at 9:46 PM, Bob Sneidar wrote: > >> only works for single characters. >> >> function substringCount pString, pChunk >> replace pString with cr & pString & cr in pChunk >> filter pChunk with pString >> retu

Re: Get number of occurrences of one string in another

2012-02-23 Thread Sumner, Walt
e number of lines of pChunk end substringCount2 OUTPUT dividing: 35 filtering: 56 6 6 true Walt On Wed, Feb 22, 2012 at 8:47 PM, Bob Sneidar wrote: Message: 22 Date: Wed, 22 Feb 2012 19:46:23 -0800 From: Bob Sneidar To: How to use LiveCode Subject: Re: Get number of occurrences of one strin

Re: Get number of occurrences of one string in another

2012-02-23 Thread Ken Ray
On Feb 22, 2012, at 9:46 PM, Bob Sneidar wrote: > only works for single characters. > > function substringCount pString, pChunk > replace pString with cr & pString & cr in pChunk > filter pChunk with pString > return the number of lines of pChunk > end substringCount Here's one that works i

Re: Get number of occurrences of one string in another

2012-02-23 Thread Peter M. Brigham, MD
;>> repeat for each char theChar in pString >>>if theChar is pChar then >>> add 1 to theCount >>>end if >>> end repeat >>> return theCount >>> end substringCount >>> >>> >&g

Re: Get number of occurrences of one string in another

2012-02-22 Thread dunbarx
eidar To: How to use LiveCode Sent: Wed, Feb 22, 2012 10:49 pm Subject: Re: Get number of occurrences of one string in another I am everyone's Uncle. Still, no repeat loops needed. See my solution. Bob On Feb 22, 2012, at 7:44 PM, Jerry Jensen wrote: > The offset() function has a th

Re: Get number of occurrences of one string in another

2012-02-22 Thread Mike Bonner
012, at 7:37 PM, Andrew Kluthe wrote: > >>> > >>>> function substringCount pChar, pString > >>>> put 0 into theCount > >>>> repeat for each char theChar in pString > >>>>if theChar is pChar then > >>>>

Re: Get number of occurrences of one string in another

2012-02-22 Thread Bob Sneidar
ar is pChar then >>>> add 1 to theCount >>>>end if >>>> end repeat >>>> return theCount >>>> end substringCount >>>> >>>> >>>&g

Re: Get number of occurrences of one string in another

2012-02-22 Thread Mike Bonner
Interesting, doesn't work the way I'd expect with find either. Seems like looking for pp in pp would find 5 matches. So I guess offset() would be the way to go if you don't want this eliminative affect. ___ use-livecode mailing list use-livecode@list

Re: Get number of occurrences of one string in another

2012-02-22 Thread Mike Bonner
eCount > >> end substringCount > >> > >> > >> Would work out nicely if there is not built in function for this. > >> > >> -- > >> View this message in context: > http://runtime-revolution.278305.n4.nabble.com/Get-number-of-occurr

Re: Get number of occurrences of one string in another

2012-02-22 Thread Bob Sneidar
>> add 1 to theCount >> end if >>end repeat >>return theCount >> end substringCount >> >> >> Would work out nicely if there is not built in function for this. >> >> -- >> View this message in context: >&

Re: Get number of occurrences of one string in another

2012-02-22 Thread Mike Bonner
There are several ways to do this i'm sure. If you want to search a field you can use find in a function for the task -- I put this in a button. Find empty ensures we start at the beginning of the field. -- the repeat loop goes until the findit function returns false, adding 1 to the total each

Re: Get number of occurrences of one string in another

2012-02-22 Thread Bob Sneidar
out nicely if there is not built in function for this. > > -- > View this message in context: > http://runtime-revolution.278305.n4.nabble.com/Get-number-of-occurrences-of-one-string-in-another-tp4412675p4412707.html > Sent fr

Re: Get number of occurrences of one string in another

2012-02-22 Thread Jerry Jensen
f there is not built in function for this. > > -- > View this message in context: > http://runtime-revolution.278305.n4.nabble.com/Get-number-of-occurrences-of-one-string-in-another-tp4412675p4412707.html > Sent from the Revolution - User mailing list archive at Nabble.com. > >

Re: Get number of occurrences of one string in another

2012-02-22 Thread Andrew Kluthe
in function for this. -- View this message in context: http://runtime-revolution.278305.n4.nabble.com/Get-number-of-occurrences-of-one-string-in-another-tp4412675p4412707.html Sent from the Revolution - User mailing list archive at Nabble.com. ___ use

Get number of occurrences of one string in another

2012-02-22 Thread David Beck
Is there any way, in the native LiveCode language, to check for the number of occurrences of one string in another? FOr example: put substringCount( "p", "apple" ) // returns 2 just curious Thanks! ___ use-livecode mailing list use-livecode@lists.run