a little help with "find" script

Mark Schonewille m.schonewille at economy-x-talk.com
Fri Mar 9 15:38:39 EST 2012


Hi Tim,

If you want to find all instances of a string, I'd use a repeat loop rather than the find command. Just loop over all fields and check whether the string is in that field. You could also use an offset or a matchChunk function. You can save all instances in a list. If you do a repeat loop over cards and fields of cards, then it is easy to store the id of the field:

repeat with x = 1 to num of cards
  repeat with y = 1 to number of fields of cd x
    put the long id of fld x of cd y into myID
    // get offset or matchchunk here
  end repeat
end repeat

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Download the Installer Maker Plugin 1.7 for LiveCode here http://qery.us/za

On 9 mrt 2012, at 21:28, Timothy Miller wrote:

> Oops. Forgot how to do this. Knew it once. I don't write scripts every day. Not even every month.
> 
> Please remind me how to write a script that finds and records every instance of a string in field "foo" I know how to write repeat loops, but can't remember how to keep finding and then exit when the last instance is found.
> 
> It would be helpful to add a user entry to the dictionary about this. If I can do it correctly and coherently, I'll add one myself.
> 
> Many cards in this stack contain field "foo" Field foo may contain none, one or many instances of the string I will be looking for.
> 
> I will  not necessarily be on card one when I start searching and the cursor may or may not be inserted in field foo. Not all cards contain field foo
> 
> Let's put all the foundchunks into tVar. I can take it from there.
> 
> After "char x to y of field z" I need to add the id of the card where the foundchunk was found. It would be convenient to know the id rather than the number of field z.
> 
> I can't remember if some function similar to the foundchunk includes the card ID of the foundchunk, or if I have to script it. The long foundchunk? Probly not...
> 
> I don't need a correct working script, just a few hints.
> 
> Your little hints save me hours of dictionary-studying and trial and error scripting. I really appreciate them.
> 
> Tim
> 





More information about the use-livecode mailing list