$next list item

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
 
(18 intermediate revisions by one user not shown)
Line 1: Line 1:
$next list item is a [[Variable Functions|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.
+
$next list item is a [[Data Functions|Data 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  
 
This function is the easiest way to loop through a list sequentially (from position 0  
 
to the end of the list).
 
to the end of the list).
 +
 +
'''List:''' The desired populated list where the next list item will be pulled from.
  
  
 
== Example ==
 
== Example ==
  
Given a list containing the numbers 1-25, we will loop through the list using the  
+
The contents of a list is used to create alerts using the next list item function. The [[Alert|alert command]] from the [[Flow Commands|flow commands]] is used to create an alert from each list item.
$next list item function:
+
 
+
[[File:nextlistitem.png]]
+
 
+
We will create the [[loop command]] using the [[$list total function]]:
+
 
+
[[File:nextlistitem0.png]]
+
 
+
Inside the loop we will use an [[if then else command]] to set a condition.
+
In this case we will simply stop the script when the list item is greater than 15:
+
 
+
[[File:nextlistitem1.png]]
+
  
Place an if/then node in the scripting area and click on the qualifier place holder to
 
highlight it. Drag a [[comparison qualifier]] (from the qualifier menu under Functions) into
 
the [[if then else command]].
 
  
For the first value, choose [[$list position]] from the variable functions menu and place it
+
<pre>add list to list(%my list, $list from text("hello,hi,how are ya", ","), "Delete", "Global")
in the area for the First value in the comparison qualifier. Select the greater than
+
set list position(%my list, 0)
symbol from the drop down menu within the qualifier labeled “Condition” and type the
+
loop($list total(%my list)){alert($next list item(%my list))}</pre>
number 15 into the area for the Second Value.
+
  
[[File:nextlistitem2.png]]
 
  
 +
[[File:Cap4.jpg]]
  
Now drag a [[stop script command]] into the Then command. Place a type text command
 
into the Else command to have it fill a field of your choice, as long as the condition we
 
set is met.
 
When run, this script will loop through the list until it reaches a list position greater
 
than 15 and stop the script. 
 
  
 +
We are populating our list with a list created from text we typed into the list from text function. Our delimiter is the comma.
 +
We are then setting the list position with the set list position command for our list to 0 so that the list starts from the beginning each time the script is run.
 +
Our loop is set to loop according to the number of items in our list. Notice the next list item function 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 ==
 
== Additional Information ==
  
  
It is important to note that if you place a [[set list position]] command just above the loop command
+
It is important to note that you must place a [[Set List Position|set list position]] command just above the [[Loop|loop command]].
you can loop through the list as many times as you like without the worry of exceeding  
+
This allows you to 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 range of the list.  The [[Set List Position|set list position]] command effectively “resets” the list back to  
 
the first position.
 
the first position.

Latest revision as of 20:51, 27 December 2016

$next list item is a Data 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).

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


[edit] Example

The contents of a list is used to create alerts using the next list item function. The alert command from the flow commands is used 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))}


Cap4.jpg


We are populating our list with a list created from text we typed into the list from text function. Our delimiter is the comma. We are then setting the list position with the set list position command for our list to 0 so that the list starts from the beginning each time the script is run. Our loop is set to loop according to the number of items in our list. Notice the next list item function inside the alert command. Each loop will pop up each list item from the list and stop when all list items have been shown.

[edit] Additional Information

It is important to note that you must place a set list position command just above the loop command. This allows you to 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.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox