$next list item

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 
This function retrieves the next item in a list. Lists have internal position counters to keep track of where you are.
 
This function retrieves the next item in a list. Lists have internal position counters to keep track of where you are.
 +
The function is found under the [[Variable Functions]].
  
 
This function will return the list item at the list's current position, and then  
 
This function will return the list item at the list's current position, and then  
Line 14: Line 15:
 
[[File:nextlistitem.png]]
 
[[File:nextlistitem.png]]
  
We will create the loop using the $list total function:
+
We will create the [[loop command]] using the [[$list total function]]:
  
 
[[File:nextlistitem0.png]]
 
[[File:nextlistitem0.png]]
  
Inside the loop we will use an if/then statement to set a condition.
+
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:
 
In this case we will simply stop the script when the list item is greater than 15:
  
Line 24: Line 25:
  
 
Place an if/then node in the scripting area and click on the qualifier place holder to  
 
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  
+
highlight it. Drag a [[comparison qualifier]] (from the qualifier menu under Functions) into  
the if then else command.
+
the [[if then else command]].
  
For the first value, choose $list position from the variables functions menu and place it  
+
For the first value, choose [[$list position]] from the variable functions menu and place it  
 
in the area for the First value in the comparison qualifier. Select the greater than  
 
in the area for the First value in the comparison qualifier. Select the greater than  
 
symbol from the drop down menu within the qualifier labeled “Condition” and type the  
 
symbol from the drop down menu within the qualifier labeled “Condition” and type the  
Line 35: Line 36:
  
  
Now drag a stop script command into the Then command. Place a type text command  
+
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  
 
into the Else command to have it fill a field of your choice, as long as the condition we  
 
set is met.  
 
set is met.  
Line 45: Line 46:
  
  
It is important to note that if you place a set list position node just above the loop node
+
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  
 
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 range of the list.  The set list position command effectively “resets” the list back to  
 
the first position.
 
the first position.

Revision as of 00:16, 10 October 2012

This function retrieves the next item in a list. Lists have internal position counters to keep track of where you are. The function is found under the Variable Functions.

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

Given a list containing the numbers 1-25, we will loop through the list using the $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 in the area for the First value in the comparison qualifier. Select the greater than symbol from the drop down menu within the qualifier labeled “Condition” and type the number 15 into the area for the Second Value.

File:Nextlistitem2.png


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.


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.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox