Filtering one list out of another
pete at lcsql.com
Tue Dec 24 10:58:53 EST 2013
I think "is among" implies wholematches = true so another way would be:
repeat with x=the number of lines in tMain down to 1
if line x of tMain is among the lines of tExcludeList then
delete line x of tMain
On Dec 23, 2013 11:29 PM, "Devin Asay" <devin_asay at byu.edu> wrote:
> 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 Asay
> Learn to code with LiveCode University
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
More information about the Use-livecode