Filtering one list out of another

Devin Asay devin_asay at byu.edu
Tue Dec 24 02:29:43 EST 2013


On Dec 24, 2013, at 12:17 AM, Dick Kriesel wrote:

> On Dec 23, 2013, at 6:19 PM, Paul Hibbert <paulhibbert at mac.com> wrote:
> 
>> …or am I missing something?
> 
> Yes, because of the way lineOffset works.  For example, if pListA is "12" and pListB is "2", then lineOffset(2,12) is 1, and an unintended delete occurs.  Avoid that by first setting the wholeMatches to true.  Then lineOffset(2,12) is 0.

This is what I ended up with:

function filterList1WithoutList2 pMainList, pExcludeList
    put pMainList into tMain
    repeat for each line tLine in pExcludeList
        set the wholeMatches to true
        put lineOffset(tLine, tMain) into tMatchedLine
        if tMatchedLine > 0 then
            delete line tMatchedLine of tMain
        end if
    end repeat
    return tMain
end filterList1WithoutList2

Works plenty fast for my fairly short lists--max number of lines to filter out is less than 36.

Thanks all for your help.

Merry Christmas!

Devin


Devin Asay
Learn to code with LiveCode University
http://university.livecode.com





More information about the use-livecode mailing list