question

Charles Carter avatar image
0 Likes"
Charles Carter asked Jacob Gillespie edited

How to copy a FlexScript cell from one table to another

I am trying to copy a table of default model input parameters (fromTable) over to another table (toTable). Some of the fromTable values are FlexScript distributions (for example - normal(2.5,05) ). I tried to use Table("toTable") [x][y] = Table("fromTable") [x][y] for each cell but it ends up putting a numeric value in the toTable (a random draw from the distribution). I want the FlexScript code in the toTable. I also tried the cloneTo function. It does the same thing. The toTable was formatted the same as the fromTable (the cells with distributions were set to be flexScript cells).

FlexSim 18.0.1
tables
· 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.

Charles Carter avatar image Charles Carter commented ·

It works by copying and pasting the table, but I'm trying to do it with code using a button to reset inputs to defaults.

0 Likes 0 ·

1 Answer

·
Jacob Gillespie avatar image
3 Likes"
Jacob Gillespie answered Jacob Gillespie edited

You could do this:

//Copy the value
Table("toTable")[x][y] = Table("fromTable").cell(x, y).value;

//Set if the cell is FlexScript
switch_flexscript(Table("toTable").cell(x, y), switch_flexscript(Table("fromTable").cell(x, y), -1));

Or this:

//Copy the cell node
createcopy(Table("fromTable").cell(x, y), Table("toTable").cell(x, y), 1, 0, 0, 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.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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