| View previous topic :: View next topic |
| Author |
Message |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Sat Apr 03, 2004 10:26 am Post subject: Help with dupe checking |
|
|
Ok, my problem this time is with dupe checking...
Here is my code I have, which does not seem to remove any dupes what so ever.
I have a list (list1) full of lines of text, some of which are the same...
I need my code to find them and remove the exact matches, this also includes uppercase and lower case matches.
| Code: | Dupe Checkmenu
DIALOG SET,STAT1,Dupe Checking enabled"," System busy...
LIST CREATE,3
%%FULL_MATCH = 0
list create,1
list create,2
List assign,1,list1
LIST SEEK,1,0
:DUPE_LOOPER
lIST ADD,2,@ITEM(1)
LIST DELETE,1
repeat
if @match(2,@ITEM(1))
if @equal(@item(1),@ITEM(2),EXACT)
LIST ADD,3,@ITEM(1)
LIST DELETE,1
%%FULL_MATCH = @fadd(%%FULL_MATCH,1)
ELSE
LIST ADD,2,@ITEM(1)
LIST DELETE,1
end
else
LIST ADD,2,@ITEM(1)
LIST DELETE,1
end
UNTIL @EQUAL(@COUNT(1),0)
list close,1
list clear,list1
list assign,list1,2
list close,2
rem IF @GREATER(%%FULL_MATCH,0)
rem GOTO Dupe_LOOPER
rem END
DIALOG SET,STAT1,@COUNT(3) dupe entries found and removed.
LIST CLOSE,3
GOTO EVLOOP |
What am I doing wrong? |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sat Apr 03, 2004 11:05 am Post subject: |
|
|
If you can use a SORTED list (the hidden ones made with
LIST CREATE), it will remove duplicates automatically.
Otherwise, ya can do something like this:
___________________________________________________________________________
| Code: |
SEE POST BELOW FOR NEW CODE
|
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361

Last edited by Mac on Sun Apr 04, 2004 1:35 pm; edited 1 time in total |
|
| Back to top |
|
 |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Sun Apr 04, 2004 9:38 am Post subject: |
|
|
I am not using a hidden list.
I really could do with a dupe feature that works with visual lists. |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sun Apr 04, 2004 11:28 am Post subject: |
|
|
If ya can use sorted data, all ya hafta to is assign it to
a hidden SORTED list, then assign it back to your visible
one.
If ya cannot use sorted data, the routine I posted will
work with a visible list as well, just change list "1" to
your list name where applicable.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Sun Apr 04, 2004 12:59 pm Post subject: |
|
|
I made the changes you suggested but it seem to get stuck in a loop at this section.
| Code: | REPEAT
if @match(1, %%item)
if @equal(@item(1), %%item)
LIST DELETE, 1
end
end
UNTIL @not(@match(1, %%item)) @equal(@index(1), %x) |
My full code is
| Code: |
:Dupe Checkmenu
LIST CREATE,1
LIST assign,1,list1
INFO Before duplicates removed:@tab()@cr()@cr()@text(1)
%x = 0
REPEAT
%%item = @item(1, %x)
if @greater(@count(1), @succ(%x))
LIST SEEK, 1, @succ(%x)
REPEAT
if @match(1, %%item)
if @equal(@item(1), %%item)
LIST DELETE, 1
end
end
UNTIL @not(@match(1, %%item)) @equal(@index(1), %x)
end
%x = @succ(%x)
UNTIL @greater(@succ(%x), @count(1))
INFO After duplicates removed:@tab()@cr()@cr()@text(1)
list assign,list1,1
list close,1
goto evloop |
|
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sun Apr 04, 2004 1:31 pm Post subject: |
|
|
OOPS...
I didn't allow for the match not being a "full match" - sorry.
Try this:
| Code: |
LIST CREATE, 1
LIST LOADTEXT, 1,
"test 1
"test 1
"test 2
"test 3
"test 3 2
"test 3
"test 4
"test 4
"test 5
"test 6
"test 7
"test 8
"test 8 1
"test 8
INFO Before duplicates removed:@tab()@cr()@cr()@text(1)
%x = 0
REPEAT
%%item = @item(1, %x)
if @greater(@count(1), @succ(%x))
LIST SEEK, 1, @succ(%x)
%%break = ""
REPEAT
if @match(1, %%item)
if @equal(@item(1), %%item)
LIST DELETE, 1
else
if @greater(@count(1), @succ(@index(1)))
LIST SEEK, 1, @succ(@index(1))
else
%%break = 1
end
end
end
UNTIL @not(@match(1, %%item)) @equal(@index(1), %x) %%break
end
%x = @succ(%x)
UNTIL @greater(@succ(%x), @count(1))
INFO After duplicates removed:@tab()@cr()@cr()@text(1)
|
EDIT - Added "@equal(@index(1), %x)" to inner loop. This
prevents a problem if duplicates are together on last two lines.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361

Last edited by Mac on Sun Apr 04, 2004 2:38 pm; edited 1 time in total |
|
| Back to top |
|
 |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Sun Apr 04, 2004 1:37 pm Post subject: |
|
|
| Thank you very much mac, you are my hero... |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sun Apr 04, 2004 1:40 pm Post subject: |
|
|
LOL, you're welcome - a real hero prolly wouldn't
have dropped the ball the first time though...
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sun Apr 04, 2004 2:51 pm Post subject: |
|
|
OOPS...
Found/fixed one more problem. Added "@equal(@index(1), %x)"
to inner loop. This prevents a problem if duplicates are together
on last two lines (it removed both). This was in the original code,
but I left it out of the re-write.
BTW, if leading/trailing spaces vary, ya may hafta use @trim()
on both elements of the @equal() comparison.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Mon Apr 05, 2004 10:32 am Post subject: |
|
|
Thanks man, your still my hero...
And thanks for letting me know via email to. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|