is among the words AND find words
Jim Hurley
jhurley0305 at sbcglobal.net
Tue Dec 20 23:31:40 EST 2011
Thanks Bob, Good thought, but it still doesn't work.
The script:
on mouseUp
put "now is the time, for all good men." into tText
set wholematches to true
--set wholematches to false
put wordOffset("time", tText) into temp1
put wordOffset("time," , tText) into temp2
end mouseUp
shows 0 for temp1 and 4 for temp2. The comma in "time," is need to get a match.
What I need is
put wordOffset("time", "Now is the time, for all good men.")
to show 4 when wholeMatches is true
It appears that there is no way in LiveCode to find whole words in a variable reliably.
Wish there were.
Jim Hurley
> 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: <F68E06CA-9008-483A-B6AD-D91E5AC1F011 at twft.com>
> Content-Type: text/plain; charset=us-ascii
>
> Not sure if wholeMatches affects the find command, but if you set wholeMatches to true and then use wordOffset("time",field "myField") then I think you will get the results you are looking for. wordOffset() returns 0 when it fails to find a match.
>
> Bob
>
>
> On Dec 20, 2011, at 4:42 PM, Jim Hurley wrote:
>
>> If the sentence:
>>
>> "Now is the time, for all good men."
>>
>> is within the field "myField" , then
>>
>> find word "time" in field "myField"
>>
>> is successful. The word "time" is found despite the fact that it is not delimited with spaces on either side.
>>
>> But
>>
>> "time" is among the words of "Now is the time, for all good men."
>>
>> returns false, since "is among the words" reads the comma after "time". It requires the spaces on either side of "time" as delimiters.
>>
>> Has this come up before and has it been suggest that this be an enhancement?
>>
>> That is to say, it would be helpful if "is among the words" and "find word(s)" behave the same with respect to the space delimiter.
>>
>> Or am I missing something?
>>
>> Jim Hurley
>> _______________________________________________
>> 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