I'd be inclined to do this:

repeat for each line...
    repeat for each item...

And check for contains as you are thinking.  This goes through tList only once. 
 (I'm assuming that tList is large and gCodes is small.)

Other ideas:

I think filter does not use a real regex.  If it does you can "compile" a regex 
from your gCodes.  Then use that single regex.  (I am only a regex expert the 
week during and the week after I do some serious regex and after that I forget 
everything.)

There might be a way to use filter if order is not important.  Filter for the 
first item to get a good list and a bad list.  Append your good list to an 
accumulating list.  Then repeat with the bad list and the next item in gCodes.  
Continue as you have items.  Your last bad list is your bad list and your 
accumulation is the good list.  (Ug.  That is cryptic.  Let me know if that 
makes no sense and I can LiveCode it.)

Variations on above would use arrays in one way or another.

LiveCode script limits are dropped.  You can compile some LiveCode from gCodes, 
somehow.  And use it somehow.  

Use matchChunk to get the first good line location.  Remove it and previous 
lines.  Save it.  Repeat.  This requires "compiling" a regex from gCodes.  

If you can pick out the code from the line, you can use the loop suggested but 
use "is among the items of" instead of the inner loop.

Put in a feature request for filtering chunks based on an expression that is 
true or false.  

Dar




On Jul 11, 2013, at 9:08 AM, Roger Eller wrote:

> global gCodes
> put tList into tGood; put tList into tBad
> put "PPX,RRY,NNZ" into gCodes
> -- Keep lines that contain any item of gCodes
> filter tGood with ("*" & item 1 of gCodes & "*") or ("*" & item 2 of gCodes
> & "*") or ("*" & item 3 of gCodes & "*")
> filter tBad without ("*" & item 1 of gCodes & "*") or ("*" & item 2 of gCodes
> & "*") or ("*" & item 3 of gCodes & "*")
> 
> Perhaps I should just loop through each line checking if it 'contains' one
> of the codes instead?
> Is there a better approach? <I'm sure there is>...
> 
> ~Roger
> _______________________________________________
> use-livecode mailing list
> [email protected]
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


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

Reply via email to