question

Martin Haas avatar image
1 Like"
Martin Haas asked Martin Haas commented

Accessing Global Tables from C++

Hello,

How do I access Global Table cell data from C++? I am trying to use the following code:

//treenode tr = model()->find("Tools/GlobalTables/ExcelData");
treenode tr = node("MODEL:/Tools/GlobalTables/globalTable");
string nodeName = tr->__getName();
pt(nodeName);
pr();
Table myTable = Table(tr);
string tableName = myTable.__name();
pt(tableName);
pr();
int tt = myTable.cell(1 ,1)->value;
//int tt = Table(tr).cell(1 ,1)->value;

It compiles fine, but throws errors when attempting to assign the value to tt.

Thanks,

Martin Haas

FlexSim 17.1.2
global table c++
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Logan Gold avatar image
0 Likes"
Logan Gold answered Martin Haas commented

I think the problem is you are referencing the Object directly instead of its table data. If you reference a Global Table using the Table() constructor and return it, you get a path to the table's data node that is a subnode of the variables node (Tools/GlobalTables/globalTable>variables/data).

So when you create the tr variable using the node() command, if you use this line instead it should work:

treenode tr = node("MODEL:/Tools/GlobalTables/globalTable>variables/data");
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Martin Haas avatar image Martin Haas commented ·

That did the trick. Thank you.

1 Like 1 ·