$list total

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
 
(4 intermediate revisions by one user not shown)
Line 1: Line 1:
$list total is a [[Variable Functions|Variable Function]]. A list's contents are numbered by their position starting from position 0. This function will return the total number of items in a list.
+
$list total is a [[Data Functions|Data Function]]. A list's contents are numbered by their position starting from position 0.  
 +
 
 +
This function will return the total number of items in a list.
 +
 
 
The function is often used along with the loop command, which allows the loop to loop according to the number of items are within the list.
 
The function is often used along with the loop command, which allows the loop to loop according to the number of items are within the list.
 +
 +
'''List:''' The desired populated list.
  
  
 
== Example ==
 
== Example ==
  
The list total function is used to set a limit for how many times the commands in the loop command can loop.  
+
The list total function is used to set a limit for how many times the commands in the loop cycles if items in a list are being used within the loop.
  
 
<pre>add list to list(%my list, $list from text("hello,hi,how are ya", ","), "Delete", "Global")
 
<pre>add list to list(%my list, $list from text("hello,hi,how are ya", ","), "Delete", "Global")
Line 14: Line 19:
 
Notice that there are three items separated by the comma in our list, which is populated using the [[$list from text|list from text function]].
 
Notice that there are three items separated by the comma in our list, which is populated using the [[$list from text|list from text function]].
  
[[File:0listtotal.png]]
+
[[File:yryr.jpg]]
  
 
Running the script will bring up an alert for each list item. The loop will stop after the last list item is presented in the [[Alert|alert command]].
 
Running the script will bring up an alert for each list item. The loop will stop after the last list item is presented in the [[Alert|alert command]].

Latest revision as of 17:03, 27 December 2016

$list total is a Data Function. A list's contents are numbered by their position starting from position 0.

This function will return the total number of items in a list.

The function is often used along with the loop command, which allows the loop to loop according to the number of items are within the list.

List: The desired populated list.


[edit] Example

The list total function is used to set a limit for how many times the commands in the loop cycles if items in a list are being used within the loop.

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))}


Notice that there are three items separated by the comma in our list, which is populated using the list from text function.

Yryr.jpg

Running the script will bring up an alert for each list item. The loop will stop after the last list item is presented in the alert command.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox