question

Patryk avatar image
0 Likes"
Patryk asked Felix Möhlmann answered

How creat new GlobalTable by code ?

How creat new GlobalTable by code ? I tried using code

Table new = applicationcommand("addglobaltable", 1) ;

and creatcopy

Unfortunately, the table I created behaves differently when setting its size or adding rows and columns.

1699433122272.png

Table "Op_Dystans" was created by use above code.

When I try to add new rows and columns, additional nodes are created and the system sees a different number of columns and rows than it actually is.

1699433707273.png


Is there another way to create a Table using code?

FlexSim 22.2.4
global tablecode
1699433122272.png (4.4 KiB)
1699433707273.png (13.4 KiB)
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

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered

The "intended" command currently is Tools.create("GlobalTable") as far as I'm aware.

Crucially, both this command, as well as the applicationcommand you are using return a reference to the table object that gets created. If you cast this as a table, the situation in your screenshot happens, where the table node structure is created as subnodes of that object. If you then later refer to it through the table constructor, it will access the data structure in the attribute tree which you didn't change.

You want to either get a reference to the proper table node by using the object name or by casting the "data" node inside the attribute tree as a table.

1699437771020.png

treenode tableObject = Tools.create("GlobalTable");
Table table1 = Table(tableObject.name); Table table2 = tableObject.find(">variables/data"); // table1 and table2 are the same table

1699437771020.png (4.3 KiB)
5 |100000

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