$previous list item

From UBot Playground
Jump to: navigation, search

$previous list item is a Data Function. The function returns the list item at the list's current position and decrements the list's position.

This function works exactly the same as $next list position except you would work from the end of a list and work up it.

So instead of looping through a list from position 0 to position 9, you loop through it from position 9 to position 0.

List: The desired populated list where the previous list item will be pulled from.


add list to list(%my list, $list from text("list item 1, list item 2,list item 3, list item 4,list item 5,list item 6", ","), "Delete", "Global")
set list position(%my list, 3)
loop(2) {
    alert($previous list item(%my list))

Setting the list position to 3 informs the list to start from list position 3 and decrements by two list position. The loop set to 2 will allow the previous list function to only decrement by two list positions.



Additional Information[edit]

The list positions are 0 based. If you have 6 items in a list, the 0 based list will number the list items from 0-5, not 1-6.