Temporary table variables
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2012
07:37 AM
11-16-2012
07:37 AM
Temporary table variables
Temporary table variables are not being stored in Table. This SmartBear example will create a table (1 row and 1 column) if one does not already exist, but no data is written to the table cells.
function TableVarTest()
{
// Create a table variable if it doesn't exist
if(!Project.Variables.VariableExists("MyTable"))
Project.Variables.AddVariable("MyTable", "Table");
// Get a reference to the variable
var t = Project.Variables.VariableByName("MyTable");
// Add columns to the table
t.AddColumn("Name");
t.AddColumn("Age");
t.AddColumn("City");
// Create two rows
t.RowCount = 2;
// Fill in the table
// The first row
t.Name(0) = "John Smith";
t.Age(0) = 24;
t.City(0) = "Seattle";
// The second row (using the Item property)
t.Item("Name", 1) = "Bob Feather";
t.Item("Age", 1) = 59;
t.Item("City", 1) = "Milltown";
}
I have not been successful in exectuting any script that is able to edit a table variable.
This on version 9.10.1894. Any suggestions are appreciated.
function TableVarTest()
{
// Create a table variable if it doesn't exist
if(!Project.Variables.VariableExists("MyTable"))
Project.Variables.AddVariable("MyTable", "Table");
// Get a reference to the variable
var t = Project.Variables.VariableByName("MyTable");
// Add columns to the table
t.AddColumn("Name");
t.AddColumn("Age");
t.AddColumn("City");
// Create two rows
t.RowCount = 2;
// Fill in the table
// The first row
t.Name(0) = "John Smith";
t.Age(0) = 24;
t.City(0) = "Seattle";
// The second row (using the Item property)
t.Item("Name", 1) = "Bob Feather";
t.Item("Age", 1) = 59;
t.Item("City", 1) = "Milltown";
}
I have not been successful in exectuting any script that is able to edit a table variable.
This on version 9.10.1894. Any suggestions are appreciated.
2 REPLIES 2
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2012
04:17 AM
11-19-2012
04:17 AM
I get it now. While the table still exixts, the variables are not retained after the script executes.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2012
04:02 AM
11-20-2012
04:02 AM
If you're looking to create tables that are persistent after a script ends I would suggest using Excel and having your script read the Excel file with the DDT.ExcelDriver to fill in your Table Variable.
