Jump to content



Photo

Displaying duplicate entries?


  • Please log in to reply
5 replies to this topic

#1 affilategod

affilategod

    Member

  • Fellow UBotter
  • PipPip
  • 15 posts
  • OS:Windows 8
  • Total Memory:2Gb
  • Framework:v3.5
  • License:Professional Edition

Posted 12 June 2014 - 10:31 PM

Instead of deleting the duplicates in a txt file, I would like to display them. I'm trying to extract the duplicates to compare txt files. Any ideas of how to do this with ubot 4? Any help would be appreciated!



#2 Gogetta

Gogetta

    Advanced Member

  • Moderators
  • 925 posts
  • OS:Windows 8
  • Total Memory:More Than 9Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 12 June 2014 - 11:48 PM

You can do this by using multiple lists.

 

Try this. You can keep hitting play a few times after the pause to see whats going on.

ui open file("Load:", #load)
clear list(%main_list)
add list to list(%main_list, $list from file(#load), "Delete", "Global")
clear list(%check_list)
add list to list(%check_list, $list from file(#load), "Don\'t Delete", "Global")
loop($list total(%main_list)) {
    set(#item_check, $next list item(%main_list), "Global")
    clear list(%total_items)
    set list position(%check_list, 0)
    loop($list total(%check_list)) {
        set(#compare_item, $next list item(%check_list), "Global")
        if($comparison(#item_check, "=", #compare_item)) {
            then {
                add item to list(%total_items, #compare_item, "Don\'t Delete", "Global")
            }
            else {
            }
        }
    }
    comment("The load html command is used just to display the duplicates found.")
    load html("Duplicates: {$list total(%total_items)}
<br/><br/>
{$text from list(%total_items, $new line)}")
    comment("Not sure what you wanted to do once the duplicates were added to %total_items. So I will just add this pause in here and you can finish coding what you need to.")
    pause script
}



#3 Kreatus (Ubot Ninja)

Kreatus (Ubot Ninja)

    Custombotsolutions.com

  • Fellow UBotter
  • PipPipPip
  • 3238 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 12 June 2014 - 11:52 PM

Here's another way to do it:

clear list(%yourlist)
clear list(%yourlist2)
clear list(%duplicates)
add list to list(%yourlist, $list from text("apple
orange
orange
banana
melon
orange
watermelon
mango
banana", "
"), "Don\'t Delete", "Global")
add list to list(%yourlist2, %yourlist, "Don\'t Delete", "Global")
loop($list total(%yourlist)) {
    set(#currentItem, $next list item(%yourlist), "Global")
    set list position(%yourlist2, 0)
    set(#checker, "", "Global")
    loop($list total(%yourlist2)) {
        set(#currentItem2, $next list item(%yourlist2), "Global")
        if($comparison(#currentItem, "=", #currentItem2)) {
            then {
                if($comparison(#checker, "=", "once")) {
                    then {
                        add item to list(%duplicates, #currentItem2, "Delete", "Global")
                    }
                    else {
                    }
                }
                set(#checker, "once", "Global")
            }
            else {
            }
        }
    }
}
alert("Duplicates:

{$text from list(%duplicates, "
")}")



#4 Gogetta

Gogetta

    Advanced Member

  • Moderators
  • 925 posts
  • OS:Windows 8
  • Total Memory:More Than 9Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 13 June 2014 - 12:00 AM

@kreatus, nice. I guess I misunderstood what he was wanting. :D



#5 Kreatus (Ubot Ninja)

Kreatus (Ubot Ninja)

    Custombotsolutions.com

  • Fellow UBotter
  • PipPipPip
  • 3238 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 13 June 2014 - 12:08 AM

@kreatus, nice. I guess I misunderstood what he was wanting. :D

 

Nope. I think your example is perfect on what he needs.. :)



#6 affilategod

affilategod

    Member

  • Fellow UBotter
  • PipPip
  • 15 posts
  • OS:Windows 8
  • Total Memory:2Gb
  • Framework:v3.5
  • License:Professional Edition

Posted 13 June 2014 - 08:14 AM

exactly what I was looking for. Thank you! How woeorduld I reorganize the list so that each word is on a seperate line, so that it's a verticle list?






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users