$table total rows

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
(Example)
Line 4: Line 4:
 
'''Table:''' The desire populated table where the table total rows will be pulled from.
 
'''Table:''' The desire populated table where the table total rows will be pulled from.
  
== Example ==
+
== Example 1 ==
  
 
<pre>
 
<pre>
Line 23: Line 23:
  
 
[[File:tabletotalrows.png]]
 
[[File:tabletotalrows.png]]
 +
 +
 +
== Example 2 ==
 +
 +
To randomize the row number while looping through the contents of the table, simply insert a [[rand]] function in place of an incrementing #row variable.
 +
 +
<pre>
 +
navigate("http://www.ubotstudio.com/playground/simple-form", "Wait")
 +
create table from file("C:\\Users\\Documents\\my table.txt", &my table)
 +
loop($table total rows(&my table)) {
 +
    set(#row, $rand(20, 300), "Global")
 +
    type text(<about me textarea>, $table cell(&my table, #row, 0), "Standard")
 +
    type text(<about me textarea>, $table cell(&my table, #row, 1), "Standard")
 +
    wait(4)
 +
}
 +
</pre>
 +
 +
The script will run the set command, assigning a random number to the variable #row.
 +
 +
The random number between the set range will determine what row the table will be pulling from.

Revision as of 13:01, 23 July 2014

$table total rows is a Data Function. This function will grab the total rows within a table. This is especially useful within a loop, when you are trying to fill a lot of fields with the contents of a certain column of information.

Table: The desire populated table where the table total rows will be pulled from.

Example 1

navigate("http://www.ubotstudio.com/playground/simple-form", "Wait")
create table from file("C:\\Users\\Documents\\my table.txt", &my table)
set(#row, 0, "Global")
loop($table total rows(&my table)) {
    type text(<about me textarea>, $table cell(&my table, #row, 0), "Standard")
    type text(<about me textarea>, $table cell(&my table, #row, 1), "Standard")
    wait(4)
    increment(#row)
}

Running the script will set the loop to loop according to how many rows are in the table. The increment command then increments the row position each time the command is run.

The script will then fill the field with items in row 0 column 0, row 0 column 1, row 1, column 0 and row 1, column 1.

File:Tabletotalrows.png


Example 2

To randomize the row number while looping through the contents of the table, simply insert a rand function in place of an incrementing #row variable.

navigate("http://www.ubotstudio.com/playground/simple-form", "Wait")
create table from file("C:\\Users\\Documents\\my table.txt", &my table)
loop($table total rows(&my table)) {
    set(#row, $rand(20, 300), "Global")
    type text(<about me textarea>, $table cell(&my table, #row, 0), "Standard")
    type text(<about me textarea>, $table cell(&my table, #row, 1), "Standard")
    wait(4)
}

The script will run the set command, assigning a random number to the variable #row.

The random number between the set range will determine what row the table will be pulling from.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox