affilategod 0 Posted June 13, 2014 Report Share Posted June 13, 2014 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! Quote Link to post Share on other sites
Gogetta 263 Posted June 13, 2014 Report Share Posted June 13, 2014 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 } Quote Link to post Share on other sites
Kreatus (Ubot Ninja) 422 Posted June 13, 2014 Report Share Posted June 13, 2014 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, " ")}") Quote Link to post Share on other sites
Gogetta 263 Posted June 13, 2014 Report Share Posted June 13, 2014 @kreatus, nice. I guess I misunderstood what he was wanting. Quote Link to post Share on other sites
Kreatus (Ubot Ninja) 422 Posted June 13, 2014 Report Share Posted June 13, 2014 @kreatus, nice. I guess I misunderstood what he was wanting. Nope. I think your example is perfect on what he needs.. Quote Link to post Share on other sites
affilategod 0 Posted June 13, 2014 Author Report Share Posted June 13, 2014 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? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.