Repeat for each

Sarah Reichelt sarah.reichelt at gmail.com
Fri Nov 4 17:23:07 EST 2005


> I have a tab delimited list (8 items per line) of about 65,000 lines.
> All but 1 item are numbers. I'm trying to set it up so that I can enter
> up to two operators per item (>,=, etc) to find a range of numbers. This
> search criteria will then be used to evaluate my big list and place the
> result into a field.
>
> For example, I may need something like this:
>
> item 2 of line x contains "word" and item 4 of line x >2 and item 8 of
> line x>50 and item 8 of line x<500
>
> I've made menu buttons that I select the operators from and a field to
> enter a value. My "Process" button would then string these conditions
> together and search the list for possible matches.
>
> I've always used the repeat with x= structure and for some reason, can't
> seem to get the repeat for each alternative. With this much data, I need
> something fast. I know even less about arrays, but perhaps they would be
> helpful as well?
>

Hi Marty,

Assuming you have the script for building your validation line, try
something like this:

repeat for each line theLine in theData
  if  item 2 of theLine contains "word" and item 4 of theLine >2 and \
    item 8 of theLine > 50 and item 8 of theLine <500 then
    -- do stuff
  end if
end repeat

However it might be possible to do a pre-selection using the filter
command. e.g. in your example, you are looking for item 2 to contain
"word". If you started by saying:
  filter theData with "*word*"
you would get rid of all the lines that didn't contain "word" at all.
The remainder may have "word" in the wrong place and the numeric tests
won't have been done, but it might shorten the starting list
significantly.

HTH,
Sarah



More information about the use-livecode mailing list