Trouble adding columns and rows to in-memory tables in FlexScript

Trouble adding columns and rows to in-memory tables in FlexScript

ABarranco
Not applicable
126 Views
5 Replies
Message 1 of 6

Trouble adding columns and rows to in-memory tables in FlexScript

ABarranco
Not applicable

[ FlexSim 23.1.1 ]

I’m trying to use in-memory tables in FlexScript to perform some calculations. However, I’m having trouble adding columns and rows to the tables. I don’t want to create Global Tables.

Here’s the script I’ve tried, but the return value is zero:

Table testTable;
testTable.setSize(4,4, DATATYPE_NUMBER);
return(testTable.numCols);

Can anyone help me figure out what I’m doing wrong?

Mensaje recibido. Sure! Here's a revised version of your text: I'm trying to use in-memory tables in FlexScript to perform some calculations. However, I'm having trouble adding columns and rows to the tables. I don't want to create Global Tables. Here's the script I've tried, but the return value is zero: ``` Table testTable; testTable.setSize(4,4, DATATYPE_NUMBER); return(testTable.numCols); ``` Can anyone help me figure out what I'm doing wrong?

0 Likes
Accepted solutions (1)
127 Views
5 Replies
Replies (5)
Message 2 of 6

joerg_vogel_HsH
Mentor
Mentor
Maybe you need another table operation, like adding values to cells.
0 Likes
Message 3 of 6

ABarranco
Not applicable

Thank you for your suggestion. I tried adding values to cells, but I got an exception error: “FlexScript exception: Invalid row number: 1 in <no path> at <no path> c: <no path> i: <no path>”.

0 Likes
Message 4 of 6

ABarranco
Not applicable

I found a solution that works, but it seems a bit unconventional. Here’s the script I used:

Array testArray;
Table testTable = testArray.as(Table);
testTable.addRow();
testTable.addCol();
return testTable.numCols;

Is there a more standard way to achieve the same result?

0 Likes
Message 5 of 6

jason_lightfootVL7B4
Autodesk
Autodesk
Accepted solution

The array approach is probably as good as any but be aware that some functions that have a table passed to them (eg. dempirical) will require a node containing the table data. In those cases you can create a temporary node and destroy it afterwards (I often create a user command called 'createtempnode' which places nodes in a new folder at 'Tools/temp' and returns a pointer to the node).

Message 6 of 6

ABarranco
Not applicable

Thank you @Jason Lightfoot! I will keep your suggestion about the nodes in mind and follow your same strategy.

0 Likes