question

Jeff Nordgren avatar image
0 Likes"
Jeff Nordgren asked Phil BoBo edited

How to update a Calculated Table from code?

@Amanda W,

Amanda is trying to update a Calculated Table from code. Here is the code that she is basically using:

treenode table = model().find("Tools/CalculatedTables/CalculatedTable1");

function_s(table, "update", 1);

She is not getting any errors but it is also not updating the values in the table. Any ideas on how to get the table to show the updated values?

Thanks.

FlexSim 17.2.2
calculated table update
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
1 Like"
Phil BoBo answered Phil BoBo edited

That code works just fine. Attached is a sample model showing it working correctly.

update-calculated-table.fsm

Run the model, then execute the script whenever you want to update the calculated table.

Note that you pass function_s() a reference to the CalculatedTable object, not a reference to its Table data.

This works:

treenode table = model().find("Tools/CalculatedTables/CalculatedTable1");
function_s(table, "update", 1);

This does not work (although it should; this is a bug which I've added to the dev list):

Table table = Table("CalculatedTable1");
function_s(table, "update", 1);

You can read the information from the table either way.

With a reference to the object, casted into a Table:

Table table = model().find("Tools/CalculatedTables/CalculatedTable1");
return table[1][2];

Or with a reference directly to the data:

Table table = Table("CalculatedTable1");
return table[1][2];

· 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.

Jeff Nordgren avatar image Jeff Nordgren commented ·

@Amanda W,

Did you see how @phil.bobo's model worked? This is exactly what you were asking for, correct? Take a look at his model and see if this will work for you.

Thanks.

0 Likes 0 ·