forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Help with dupe checking

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Sat Apr 03, 2004 10:26 am    Post subject: Help with dupe checking Reply with quote

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
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sat Apr 03, 2004 11:05 am    Post subject: Reply with quote

If you can use a SORTED list (the hidden ones made with
LIST CREATE), it will remove duplicates automatically. Wink

Otherwise, ya can do something like this:
___________________________________________________________________________
Code:

SEE POST BELOW FOR NEW CODE


Cheers, Mac Smile

_________________
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
View user's profile Send private message Send e-mail
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Sun Apr 04, 2004 9:38 am    Post subject: Reply with quote

I am not using a hidden list.
I really could do with a dupe feature that works with visual lists.
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sun Apr 04, 2004 11:28 am    Post subject: Reply with quote

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. Wink

Cheers, Mac Smile

_________________
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
View user's profile Send private message Send e-mail
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Sun Apr 04, 2004 12:59 pm    Post subject: Reply with quote

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
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sun Apr 04, 2004 1:31 pm    Post subject: Reply with quote

OOPS... Embarassed

I didn't allow for the match not being a "full match" - sorry. Confused

Try this: Wink
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 Smile

_________________
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
View user's profile Send private message Send e-mail
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Sun Apr 04, 2004 1:37 pm    Post subject: Reply with quote

Thank you very much mac, you are my hero...
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sun Apr 04, 2004 1:40 pm    Post subject: Reply with quote

LOL, you're welcome - a real hero prolly wouldn't
have dropped the ball the first time though... Wink Laughing

Cheers, Mac Smile

_________________
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
View user's profile Send private message Send e-mail
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sun Apr 04, 2004 2:51 pm    Post subject: Reply with quote

OOPS... Embarassed

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. Confused

BTW, if leading/trailing spaces vary, ya may hafta use @trim()
on both elements of the @equal() comparison. Wink

Cheers, Mac Smile

_________________
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
View user's profile Send private message Send e-mail
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Mon Apr 05, 2004 10:32 am    Post subject: Reply with quote

Thanks man, your still my hero...

And thanks for letting me know via email to.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group