newbie script question re Find command

J. Landman Gay jacque at hyperactivesw.com
Tue Mar 22 18:30:55 EDT 2011


On 3/22/11 4:31 PM, Timothy Miller wrote:

> How do I find multiple instances of a string in a given field of a
> given card and record each foundchunk in a variable, and then stop
> repeating the find command when the last instance is found?

It's simpler than you'd think. Unlike HyperCard, LiveCode reports "not 
found" as soon as the last instance has been located. So all you have to 
do is repeat the find command until the result is "not found". You don't 
have to manage any card or field loops, the engine does it all.

Off the top of my head:

put "thing to find" into tVar
repeat
  find tVar [in field "thisField"]
  if the result = "not found" then exit repeat
  put the foundchunk & cr after tFoundList
end repeat

This will go through all the cards and fields by itself. I didn't test 
it, so you do that. ;) I probably forgot something.

Note that if you interrupt the find command it will lose its place, so 
let the repeat loop continue until it's done.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list