When is a Word not a Word?

Peter Haworth pete at mollysrevenge.com
Mon Jan 10 13:01:48 EST 2011

Thanks for the explanation, I guess it's the wording in the dictionary that is not really clear (at least to me).  I think your example of having white space within quotes brought home the intention behind it all.

You get the correct xyz results because you enclosed the string to search for in quotes.  My problem was because I was trying to find a string not in quotes in the search field and it was in quotes in the search field.  I've worked around the problem now by searching both with and without quotes.

I know about the various different find/replace functions in LC and wonder why there are three of them that all work slightly differently, but that's another story.  I think the Find/Replace function you get from the Edit Menu when a script editor window is not in focus does what I want for scripts but, as mentioned in an earlier email, it wreaked (wrought?) havoc on my custom properties when I tried to search for a specific one and replace it with a different name.

I've written my own script to globally change the name of a custom property and it's working fine.  I've also realised that looking for strings in a script is pretty complicated because of the many string delimiters that could be present - quotes, comma, open and close brackets, open and close square brackets, etc - so I'll go back to the Find/Replace for that.  I guess I could try using a regular expression but they seem so far removed from the English-like syntax of the rest of LC that I don't think I want to get involved with them!
Pete Haworth

On Jan 9, 2011, at 6:58 PM, J. Landman Gay wrote:

> On 1/9/11 6:05 PM, Peter Haworth wrote:
>> So is the dictionary wrong or am I just misunderstanding it?  It says
>> a word is something enclosed in quotes.  Is it implying that the
>> quotes are part of the word, not delimited by it?
> It's confusing, but it's sort of both. Counting everything within double quotes as a single word is historical HyperCard behavior. That makes it easy to do things like extract the name of a stack:
>  get the name of this stack -- 'stack "Message Box"'
>  put word 2 of it -- "Message Box"
> Note though that you still need to strip the quotation marks if you don't want them, so quotes really are still part of the "word" chunk. Basically words are delimited by white space, but inside a quoted string the white space is ignored, at least for the purposes of text chunking.
> The offset functions also respect the double-quote rule:
> get the name of this stack -- 'stack "Message Box"'
> put wordoffset("box",it) -- 2
> put wordoffset("message",it) -- 2
> But offset functions do ignore the quotes when looking for a match (which means I mislead you in my last message.) I just tried your example and I get what you'd expect. I'm not sure why our results are different:
>  get "abc def" && quote& "xyz" &quote
>  put wordoffset("xyz",it)
> I get 3.
>> Any suggestions on how to do this?  Maybe put quote & "xyz" &
> > quote into a variable and search for it?
> Yes, I think that's what you'd need to do. It will force the engine to evaluate the string before using it.
> But even easier, do you know about the built-in script editor replace? It's in the Edit menu when a script editor is open. Or click the More button next to the Find field if it's already showing. It beats writing your own.
> -- 
> Jacqueline Landman Gay         |     jacque at hyperactivesw.com
> HyperActive Software           |     http://www.hyperactivesw.com
> _______________________________________________
> 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