$list position

From UBot Playground
Jump to: navigation, search

$list position is a Data Function. The function returns the position of a specific list item.

This command is similar to the list total command, except, instead of returning the total for an entire list, it will return the list position of the current item. This function works with the next list item function and the previous list item functions.

List: The desired populated list.


Example[edit]

One of the many to see the list position function at work is by displaying it.

Adding the list position function into the alert command next to the next list item function brings up the list item and the list position of the list item.

Notice that the next list item function and the list position function are separated by commas.

add list to list(%my list, $list from text("hello,hi,how are ya", ","), "Delete", "Global")
set list position(%my list, 0)
loop($list total(%my list)) {
    alert("{$next list item(%my list)},{$list position(%my list)}")
}

List item 1 at list position 1 Listposition.png

List item 2 at list position 2 Listposition1.png

List item 3 at list position 3 Listposition2.png