another question about finding duplicates
Klaus Major
klaus at major-k.de
Sun Jan 27 07:53:26 EST 2008
Hi Peter,
> There's a file which goes roughly:
>
> 1 anything
> 2 anything
> 3 anything
> 4 anything
>
> etc
>
> It can always be sorted by the first item. Sometimes a duplicate
> entry will
> creep in, so the file will look
>
> 1 anything
> 2 anything
> 2 anything
> 3 anything
> 4 anything
>
> or perhaps
>
> 1 anything
> 2 anything
> 3 anything
> 3 anything
> 4 anything
>
> What's the quickest way of checking for this condition - when the
> two items 1
> of any two adjacent lines are identical? I have found a brute force
> way to
> do it using filter, but it is really clunky and slow.
use a very smart "repeat for each" loop ;-)
on mouseUp
put fld 1 into tList
## or whatever...
set itemdel to TAB
## so we chan check the first time...
put empty into tPrev_item1
repeat for each line i in tList
if item 1 of i <> tPrev_item1 then
put i & CR after tNewlist
end if
## so we can check this item of the line BEFORE the actual line
(i) :-)
put item 1 of i into tPrev_item1
end repeat
## get rid of trailing CR
delete char -1 of tNewlist
put tNewlist into fld 2
end mouseUp
Tested and works.
Of course you MUST sort the lines first by item 1!
> Cheers
>
> Peter
Regards
Klaus Major
klaus at major-k.de
http://www.major-k.de
More information about the use-livecode
mailing list