Jump to content
UBot Underground

Displaying duplicate entries?


Recommended Posts

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!

Link to post
Share on other sites

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
}

Link to post
Share on other sites

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, "
")}")

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...