$next list item
(→Example) |
(→Example) |
||
Line 9: | Line 9: | ||
<pre>add list to list(%my list, $list from text("hello,hi,how are ya", ","), "Delete", "Global")</pre> | <pre>add list to list(%my list, $list from text("hello,hi,how are ya", ","), "Delete", "Global")</pre> | ||
− | + | <pre>set list position(%my list, 0)</pre> | |
+ | <pre>loop($list total(%my list)){alert($next list item(%my list))}</pre> | ||
[[File:nextlistitem.jpg]] | [[File:nextlistitem.jpg]] | ||
+ | [[File:nextlistitem0.jpg]] | ||
+ | [[File:nextlistitem1.jpg]] | ||
We are populating our list with a list created from text we typed into the list from text command. Our delimiter is the comma. | We are populating our list with a list created from text we typed into the list from text command. Our delimiter is the comma. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
We are then setting the list position for our list to 0 so that the list starts from the beginning each time the script is run. | We are then setting the list position for our list to 0 so that the list starts from the beginning each time the script is run. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
This loop is set to loop according to the number of items in our list. Notice the list item inside the alert command. Each loop will pop up each list item from the list and stop when all list items have been shown. | This loop is set to loop according to the number of items in our list. Notice the list item inside the alert command. Each loop will pop up each list item from the list and stop when all list items have been shown. | ||
Revision as of 00:40, 11 October 2012
$next list item is a Variable Function. Lists have internal position counters to keep track of where you are. This function will return the list item at the list's current position, and then increment the list's position by one. This function is the easiest way to loop through a list sequentially (from position 0 to the end of the list).
Example
In this example, we use the next list item to populate a list, and we will use the alert command from the flow commands to create an alert from each list item.
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))}
File:Nextlistitem.jpg File:Nextlistitem0.jpg File:Nextlistitem1.jpg
We are populating our list with a list created from text we typed into the list from text command. Our delimiter is the comma. We are then setting the list position for our list to 0 so that the list starts from the beginning each time the script is run. This loop is set to loop according to the number of items in our list. Notice the list item inside the alert command. Each loop will pop up each list item from the list and stop when all list items have been shown.
Additional Information
It is important to note that if you place a set list position command just above the loop command you can loop through the list as many times as you like without the worry of exceeding the range of the list. The set list position command effectively “resets” the list back to the first position.