question

shanice.c avatar image
0 Likes"
shanice.c asked shanice.c edited

How to use Code Snippet?

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

FlexSim 21.2.0
global tableflexsim 21.2.0code snippet
圖片.png (458.3 KiB)
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

·
Matthew Gillespie avatar image
1 Like"
Matthew Gillespie answered shanice.c edited

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

shanice.c avatar image shanice.c commented ·

@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 0 ·

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.