Perhaps a slight improvement for the count of items/lines appears at the end.
On 6/15/06 5:18 PM, "Alex Tweedly" <[EMAIL PROTECTED]> wrote: > Mark Smith wrote: > >> >> On 16 Jun 2006, at 00:47, Jared Smith wrote: >> >>> Here are a few things that I've been confused about: >>> >>> 1) How do I find the number of times a certain character appears in a >>> string? The "offset" function only finds the first occurance, it >>> doesn't count them. >>> >> >> This function should work: >> >> function charCount tText,tChar >> set the itemDelimiter to tChar >> return the number of items in tText - 1 >> end charCount >> > Watch out for the case where the last character in the string is the one > you are interested in; because there isn't an item after it, this gives > the wrong result - I'd use > > function charCount tText,tChar > set the itemDelimiter to tChar > if char -1 of tText = tChar then > return the number of items in tText > else > return the number of items in tText - 1 > end if > end charCount > Another approach I use for the "last item empty" scenario you mention, Alex, is return the number of items in (tText&null) --now the count will be correct ---and very unlikely that you would choose an itemDel of null The same for repeat loops... repeat with x = 1 to the number of items in (tText&null) --do the right number of loops end repeat repeat with x = 1 to the number of lines in (tText&null) Jim Ault Las Vegas _______________________________________________ use-revolution mailing list [email protected] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
