Using the "or" operator with filter

Richard Gaskin ambassador at fourthworld.com
Thu Jul 11 13:18:17 EDT 2013


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?

I would do that.

Regex is handy at times, but it's a complex subsystem and notoriously 
slow with complex operators.

I'll bet if you can first run a filter against the left-most column, a 
"repeat for each" on the remainder would likely be about as fast as you 
can get.

Sometimes "repeat for each" on the whole thing is faster than "filter".

--
  Richard Gaskin
  Fourth World
  LiveCode training and consulting: http://www.fourthworld.com
  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
  Follow me on Twitter:  http://twitter.com/FourthWorldSys




More information about the use-livecode mailing list