question

Axel Kohonen avatar image
0 Likes"
Axel Kohonen asked Axel Kohonen commented

Setting a table into bundle mode with FlexScript

Hi,

Is it possible to set a table to use bundle mode with FlexScript? I create the tables at model reset and for the larger ones I would like to set them into bundle mode. I have so many tables that doing it manually takes way too long.

If the option above is not possible then another option is to create the table by copying a table and then copying the variables node from a table that is in bundle mode, but I would like to avoid that if possible as then I need to have an extra table in the model just for copying.

Thank you!

Kind regards,

Axel

FlexSim 17.2.5
custom codetablesbundle
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

Phil BoBo avatar image
2 Likes"
Phil BoBo answered Axel Kohonen commented

After creating the table, the following script will change its data from regular to bundle:

treenode data = Table("GlobalTable1");
treenode newData = nodeinsertafter(data);
setname(newData, getname(data));
nodeadddata(newData, DATATYPE_BUNDLE);
data.as(Table).cloneTo(newData.as(Table));
destroyobject(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.

Axel Kohonen avatar image Axel Kohonen commented ·

Hi @phil.bobo

Thank you!

And if someone creates the table with

treenode table = createinstance(...)

then remember that table returned by createinstance is a reference to the table node itself and not the data node as when referencing a table with Table("GlobalTable1"). So to get the data node from the table one needs to use

treenode data = table.find(">variables/data")

This is important as new tables are created with the name GlobalTable1 if a table with that name does not exist. So Phil's code above works as long as there is no table with the name GlobalTable1 already. If not sure then one can get the data reference as here.

1 Like 1 ·