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         |     jac...@hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to