Labelvalue in tabel

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
Simulerings Mads
Posts: 4
Joined: Monday 11 April, 2022 - 12:00

Labelvalue in tabel

Post by Simulerings Mads »

Hey

I'm trying to simulate a production system for a university project. There is a total of 5 operations, which is sequenced after Earliest due date. I've assigned a label called Duedate in the source atom with a value from a empirical distribution table. The duedate value represent the maximum days the product can be in the system before it will be delivered late.

I've used the following code in the trigger on entry in the sink atom to put the throughput time and Duedate value in a table.
Do(
SetTable(
nrows(refTimeData)+1,
1,
refTimeData
),
SetTimeData(
nrows(refTimeData),
1,
Age(i)
),
SetTimeData(
nrows(refTimeData),
2,
GetLabel("DueDate", i)
)
)
The first part works perfectly without the last 6 lines of the script. It says the Duedate is not a valid expression, even though when i pause the simulation and press a product and go to Atom Labels in the menu i can see that each product has been assigned Duedate and a associated value. The name and capital letters are identical when the label is created and in the code above.

How can i get the script to regonize the duedate label?

Best regards
Mads
Gabe-Hein Dijkstra
Posts: 24
Joined: Friday 13 May, 2022 - 10:16

Re: Labelvalue in tabel

Post by Gabe-Hein Dijkstra »

Hi Mads,

I think you are already quite close to the correct code. Two remarks:
  • A string should be placed between closed brackets, hence [DueDate] instead of "DueDate".
  • Instead of GetLabel, I would recommend using Label. See the Help for more information.
I hope this helps!

Kind regards,
Gabe-Hein
Simulerings Mads
Posts: 4
Joined: Monday 11 April, 2022 - 12:00

Re: Labelvalue in tabel

Post by Simulerings Mads »

Hey Gabe-Hein

I've corrected the things you mentioned. The simulation is able to run, but when the product reaches the sink it returns the following error
"Trying to set cell (r,c) : (2275,2) , last row = 2275, last column = 1 -> Timedata (AtomID: 196), FUNCTION: SetTimedata (Ln: 1, Col: 1) "SetCell" | Time: 94.3482860286064, c: Sink12 (AtomID: 208), i: Product (AtomID: 239), OnEntered, EventCode: 6"

Do you have a fix for this problom? :))

Best regards
Mads
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Labelvalue in tabel

Post by HarryBunnik »

Hi Mads,

This normally is an error that you're writing in a column (no. 2) which is not defined in your table (you only have 1 column), so it can't write there.

So, either the writing of a value into the table is wrong, and it should be column 1, instead of column 2. Or your table is too small and you need to add an extra column.

Gr. Harry
Post Reply