$list from table
(→Example 2) |
|||
(6 intermediate revisions by one user not shown) | |||
Line 8: | Line 8: | ||
'''Index:''' The number of the desired column or row within the table. For example "Row 1". | '''Index:''' The number of the desired column or row within the table. For example "Row 1". | ||
− | == Example == | + | |
+ | == Example 1 == | ||
+ | |||
<pre> | <pre> | ||
Line 21: | Line 23: | ||
− | [[File: | + | [[File:lft0.png]] |
Line 38: | Line 40: | ||
− | [[File: | + | [[File:lft1.png]] |
+ | |||
+ | |||
+ | == Example 2 == | ||
+ | |||
+ | Need to insert an item into a specific list position? | ||
+ | |||
+ | You can use the list from table function to do just that. | ||
+ | |||
+ | <pre> | ||
+ | navigate("http://listofrandomnames.com/index.cfm?generated", "Wait") | ||
+ | wait(6) | ||
+ | click(<type="submit">, "Left Click", "No") | ||
+ | wait(6) | ||
+ | add list to list(%names, $scrape attribute(<innertext=r"^(?<FirstName>\\w+)\\s(?<LastName>\\w+)$">, "innertext"), "Delete", "Global") | ||
+ | add list to table as column(&editing, 0, 0, %names) | ||
+ | plugin command("TableCommands.dll", "insert into table", &editing, "Row", 5) | ||
+ | set table cell(&editing, 5, 0, "Manny Su") | ||
+ | clear list(%names) | ||
+ | add list to list(%names, $plugin function("TableCommands.dll", "$list from table", &editing, "Column", 0), "Delete", "Global") | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | [[File:lft2.png]] | ||
+ | |||
+ | |||
+ | The position we want to insert the list item to is list position 5. | ||
+ | |||
+ | We then insert a blank cell, set the table cell value to the new value, which is the name Manny Sue, and then we clear the original list and create a new list from the edited table column |
Latest revision as of 21:28, 12 November 2014
$list from table is a Data Function.
This function will return the contents of a specified row or column as list items. The function is used along with the add list to list command to create a list with the contents of a table.
Table: The populated table with the desired items.
Row or Column: Allows the return of the contents of an entire for or an entire column as a list.
Index: The number of the desired column or row within the table. For example "Row 1".
[edit] Example 1
navigate("http://w3schools.com/html/html_colornames.asp", "Wait") wait(3) scrape table(<innertext="Color Name">, &MyTable) add list to list(%my list, $plugin function("TableCommands.dll", "$list from table", &MyTable, "Row", 0), "Delete", "Global")
Running this script will populate the list with the contents in Row 0.
navigate("http://w3schools.com/html/html_colornames.asp", "Wait") wait(3) scrape table(<innertext="Color Name">, &MyTable) add list to list(%my list, $plugin function("TableCommands.dll", "$list from table", &MyTable, "Column", 0), "Delete", "Global")
Running this script will populate the list with the contents in Column 0.
[edit] Example 2
Need to insert an item into a specific list position?
You can use the list from table function to do just that.
navigate("http://listofrandomnames.com/index.cfm?generated", "Wait") wait(6) click(<type="submit">, "Left Click", "No") wait(6) add list to list(%names, $scrape attribute(<innertext=r"^(?<FirstName>\\w+)\\s(?<LastName>\\w+)$">, "innertext"), "Delete", "Global") add list to table as column(&editing, 0, 0, %names) plugin command("TableCommands.dll", "insert into table", &editing, "Row", 5) set table cell(&editing, 5, 0, "Manny Su") clear list(%names) add list to list(%names, $plugin function("TableCommands.dll", "$list from table", &editing, "Column", 0), "Delete", "Global")
The position we want to insert the list item to is list position 5.
We then insert a blank cell, set the table cell value to the new value, which is the name Manny Sue, and then we clear the original list and create a new list from the edited table column