is among the words AND find words
jhurley0305 at sbcglobal.net
Wed Dec 21 12:40:44 CST 2011
Bob et. al.
> Message: 14
> Date: Wed, 21 Dec 2011 08:24:59 -0800
> From: Bob Sneidar <bobs at twft.com>
> To: How to use LiveCode <use-livecode at lists.runrev.com>
> Subject: Re: is among the words AND find words
> Message-ID: <BA41A52B-8B6E-4DC0-9996-1253098EAB57 at twft.com>
> Content-Type: text/plain; charset=us-ascii
> I think this underscores the need for the words keyword to be upgraded to reflect real text. For instance, word delimiters could be a property containing all the characters which might be word delimiters, all the punctuations for example. I don't know how you would treat a hyphen.
That would work.
> Upon thinking about it, I am not sure what the application would be for finding specific words in an english (or any other languages) phrase. It is useful for finding keywords in a Livecode statement for sure.
The application would be one of gatering all the lines in a text field that contain a word or words and displaying them in a second field. The text might also include quotes and that messes up the wordOffset function.
Turns out the tokens don't work since the period is not a token so the token 1 of "time." is time.
Astonishingly, it turns out that LC all allows for
Put "time" is among the tokens of "Now is the time, for all good men."
That returns true.
Put "men" is among the tokens of "Now is the time, for all good men."
returns false--because of the period after "men"
I think I'll just strip the lead and trailing characters from the resulting wordOffset word, using something like:
function stripEnds tWord
if charIsNotLetter (char 1 of tWord) then
delete char 1 of tWord
if charIsNotLetter (char -1 of tWord) then
delete char -1 of tWord
function charIsNotLetter tChar
put charToNum(tChar) into tNum
case tNum >= charToNum("a") and tNum <= charToNum("z")
case tNum >= charToNum("A") and tNum <= charToNum("Z")
But I would prefer RR to implement your suggestion of augmenting the delimiters for "word" to include all non-letters.
More information about the use-livecode