Jump to content
UBot Underground

Subtracting one list from another list without Ubot Dev?


Recommended Posts

I have Ubot Studio and I am looking for a way to remove one list of items from another list.  I understand the Developer version has a command to do this ($subtract lists) however that isn't available to me. Is there a "manual" way to do this?

 

Thanks for your help.

 

Joe

Link to post
Share on other sites

It's actually pretty simple, you just need to loop through the main list once and remove item if it's in another list.

 

Here is an example:

clear list(%LIST Original)
add list to list(%LIST Original, $list from text("item1,item2,item3", ","), "Delete", "Global")
clear list(%LIST Substract)
add list to list(%LIST Substract, $list from text("item1,item3", ","), "Delete", "Global")
set(#LIST Original Row, 0, "Global")
loop($list total(%LIST Original)) {
    if($contains(%LIST Substract, $list item(%LIST Original, #LIST Original Row))) {
        then {
            remove from list(%LIST Original, #LIST Original Row)
        }
        else {
            increment(#LIST Original Row)
        }
    }
}

After running the code result can be found in list %LIST Original.

 

Also notice that UBot's $contains function will also return true if you check the list if it contains "item", "ite", "it" and "i",... that's why you would need to write a custom function for that part if $contains doesn't meet your requirements.

  • Like 1
Link to post
Share on other sites

Thanks for the quick and detailed reply. I think this will work for my needs... I am scraping all internal URLs from a website so I need to remove pages/urls already scanned from a "to do" list and place them in the "final list". 

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