Remove From List

From UBot Studio
Revision as of 16:21, 22 May 2014 by LillyT (Talk | contribs)

Jump to: navigation, search

Remove From List is a Data Command.

This command will remove a list item by list position.

List: The list the item will be removed from.

Position: The position of the item that is going to be removed.


Example 1

navigate("http://www.fruitsinfo.com/tropical-fruits.php", "Wait")
add list to list(%one, $scrape attribute(<href=w"http://www.fruitsinfo.com/*.php">, "innertext"), "Delete", "Global")
remove from list(%one, 0)

Notice that there is nothing in the list position 0. It is just taking up space without any value.


Remove.jpg


Setting the list position in the remove from list command to 0 allows us to remove that blank space. Notice that the rest of the list move up.

No empty space is left in the script.


Remove0.jpg


Example 2

The following example removes the last two lines from a list.

The script is populated with the following values created and delimited with a comma with the list from text command:

a
b
c
d

The loop will loop twice to remove the list items based on the list total, minus 1.

Keep in mind that lists are zero based. For example, the list total of a list might be 20, but the last list item within the list is on list position 19.

In a list containing 20 items, the list position starts at 0 and ends at 19.



add list to list(%blue, $list from text("a,b,c,d", ","), "Delete", "Global")
loop(2) {
    remove from list(%blue, $subtract($list total(%blue), 1))
}


When the script runs, list item c and d will be removed from the list.

To remove the last 3 items within a list, change the loop cycle to 3.

To remove the last 4 items of a list, change the loop cycle to 4, and so on.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox