How to use Code Snippet?

How to use Code Snippet?

shanice_c
Not applicable
110 Views
2 Replies
Message 1 of 3

How to use Code Snippet?

shanice_c
Not applicable

[ FlexSim 21.2.0 ]

I would like to write box entry time to global table, but if product has been processed, the entry time would be write to Column 8 of the table; if has not been processed, the entry time would be write to Column 4 of the table. I use an integer "tempCol" to distinguish which column should be written to, but seems not work in Write To a GlobalTable Trigger. May I use Code Snippet like this?圖片.png

0 Likes
Accepted solutions (1)
111 Views
2 Replies
Replies (2)
Message 2 of 3

Matthew_Gillespie
Autodesk
Autodesk
Accepted solution

Those two popups have different scope and so you can't define a variable in one and use it in the other. You could assign the value to a label on the item (item.TempCol = 4) and then read it off in the global table popup (item.TempCol).

Or instead of using the Write to a Global Table option, just write the single line of code it takes to write to a global table in the code snippet:

Table("CSTTimeTable")[item.TableRow][tempCol] = Model.time;

OR instead of using the Code Snippet, just write a single line in the Column field of the Write to a Global Table option:

item.StageComplete ? 8 : 4


Matthew Gillespie
FlexSim Software Developer

Message 3 of 3

shanice_c
Not applicable

@Matthew Gillespie Thank you for the quick response!

May I ask if there's limitation for number of triggers that could be used ? I use many triggers to record some information, and sometimes find some triggers I've set disappeared.(ex: some values that should be written to a cell is not written out, I checked through and found the last 1 or 2 triggers didn't exist there.

0 Likes