newbie script question re Find command

Terry Judd tsj at unimelb.edu.au
Tue Mar 22 18:38:02 EDT 2011


Here are some things to start working with...

1. the cardNames function - gives you a list of cards for the specified
stack. You can then loop through each card in turn using a repeat loop of
the form...

repeat for each line tCd in (the cardNames of this stack)

...alternatively you can just

repeat with I = 1 to the number of cds in this stack

2. the offset function - which is what you'll use inside another repeat loop
(inside the first repeat structure) to find all the instances of your string
in a field. For example you could use the 'repeat forever' form to continue
searching a field until the offset function returns 0. Your offSet routine
includes a charsToSkip parameter (check out the dictionary entry). In the
first pass of a field this is set to 0, then if you get a match, you record
the value and pass it in the charsToSkip parameter in the next iteration of
the repeat loop.

As far as recording all the chunks goes, you probably only need to store the
offset values (along with the field and card names), as given you already
know the length of the original search string you can easily create chunk
statements from these when required.

HTH,

Terry...


On 23/03/11 8:31 AM, "Timothy Miller" <gandalf at doctorTimothyMiller.com>
wrote:

> Hiya,
> 
> I guess I never tried to write a script like this before. Thought it would be
> simple... Well, it is simple, probably, just not simple in a way that I
> actually understand.
> 
> 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?
> 
> I want to do this in the context of a repeat loop that goes to all the cards
> in the stack in sequence.
> 
> Sooo, I also need to know... How do I tell the repeat loop to move on to the
> next card:
> 
> - if no instance of the string is found on the card
> 
> - and
> 
> - after the last instance of the string is found on the card
> 
> Hope that's clear.
> 
> I understand I'll probably want to nest a repeat loop using the find command
> on each card, with exits when certain conditions are met. I'm choking on the
> details.
> 
> I don't need a complete and accurate script. Just the general idea.
> 
> Thanks in advance.
> 
> Tim (the world's oldest newbie)
> _______________________________________________
> 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
> 

--
Dr Terry Judd | Senior Lecturer in Medical Education
Medical Education Unit
Melbourne Medical School
The University of Melbourne







More information about the use-livecode mailing list