You can traverse through the nodes under VIEW:/active in order to find a particular window that is open. For example, this code will find an open global table view that is focused on InputTable:
treenode tableNode = Table("InputTable");
treenode tableView = NULL;
treenode openTableViews = node("VIEW:/active>Documents/Table");
for (int r = 1; r <= content(openTableViews); r++) {
treenode openTableView = node("TableView", ownerobject(tonode(get(rank(openTableViews, r)))));
treenode openTableNode = node(">viewfocus+", openTableView);
if (openTableNode == tableNode) {
tableView = openTableView;
}
}
return tableView;
You could also use the createview() command to open the table's properties window, which will open the view if it isn't already open and activate it.
treenode tableNode = Table("InputTable");
createview(gets(guifocusclass(ownerobject(tableNode))), nodetopath(ownerobject(tableNode)));
You can combine all three of these code snippets together to accomplish what you are trying to do:
int goToRow = 13450;
treenode tableNode = Table("InputTable");
createview(gets(guifocusclass(ownerobject(tableNode))), nodetopath(ownerobject(tableNode)));
treenode tableView = NULL;
treenode openTableViews = node("VIEW:/active>Documents/Table");
for (int r = 1; r <= content(openTableViews); r++) {
treenode openTableView = node("TableView", ownerobject(tonode(get(rank(openTableViews, r)))));
treenode openTableNode = node(">viewfocus+", openTableView);
if (openTableNode == tableNode) {
tableView = openTableView;
}
}
if (!objectexists(tableView))
return 0;
double nMin = scrollinfo(tableView, 0, 1, 1);
double nMax = scrollinfo(tableView, 0, 1, 2);
double nPage = scrollinfo(tableView, 0, 1, 3);
double nPos = scrollinfo(tableView, 0, 1, 4);
if (nMax < 32767) {
scrollinfo(tableView, 1, 1, 4, goToRow - 1);
repaintview(tableView);
return 0;
}
treenode tableDataNode = node(">viewfocus+", tableView);
double totalRows = tableDataNode.as(Table).numRows;
double pos = goToRow / totalRows * (nMax - nPage);
scrollinfo(tableView, 1, 1, 4, pos);
repaintview(tableView);
Phil BoBo
Sr. Manager, Software Development