problem with counting words

Jerry Jensen jhj at jhj.com
Sun Oct 12 15:26:48 EDT 2014


Ah, and then there are tabs to deal with, and double-spaces will count an empty item between. It may be better to just replace the quotes with curly-quotes, count the words, and then replace the curly-quotes back to quotes if you want.

On Oct 12, 2014, at 12:20 PM, Jerry Jensen <jhj at jhj.com> wrote:

> Hi Larry,
> 
> the itemDel is the character that delimits ITEMS, not words. You could use it to get around your problem with quotes. If you set the itemDel to space, you would then look for the number of ITEMS in the field. Thats not quite the end of it though, because there may not be a space between lines in the field, only returns. So, you could add up the number of items in each line - something like:
> 
> put 0 into tCount
> set the itemDel to space
> repeat for each line L in field "foo"
>  add the number of items in L to tCount
> end repeat
> 
> (not tested)
> 
> .Jerry
> 
> On Oct 12, 2014, at 11:17 AM, larry at significantplanet.org wrote:
> 
>> Hello,
>> 
>> I'm posting this to help any other poor saps who run into this insanity:
>> 
>> I want to count the words in a field.  I have:
>> 
>> set the itemDel to space
>> 
>> put the number of words of field "myTest" into field "myNumber"
>> 
>> 
>> 
>> Here is what happens:
>> 
>> I am testing the word count in LiveCode 6.1.1. Believe it or not, LiveCode will count all these words 
>> 
>> as 23 words "because everything contained within the quotes is counted as ONE word!!!"
>> 
>> 
>> 
>> There is nothing that I could find that says LiveCode will treat everything within quotes as one word, even when I have itemDel set to space.
>> 
>> I doubt the RunRev people will see this as a bug, but "just how it is."  Well, it's really stupid - and beyond that, it is not documented in the Dictionary that I could see.
>> 
>> btw, I spoke to a programmer friend of mine (who used to work for Novell) and he said he'd never heard anything like that in the several programming languages he knows.
>> 
>> Yes, I do know how to do a work around to count all the actual words, but that is not the point.  The point is that I wasted over 2 hours of my time figuring out why my word count was inaccurate.
>> 
>> quite depressed,
>> 
>> Larry
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list