question

Sonia A avatar image
0 Likes"
Sonia A asked Sonia A commented

How to automatically call slot labels with code

Hello Everybody,

I am working on a model in Flexsim in which I would like to automatically create labels in a storage system based on the number of pallets that I store in the slot. I have used this code and it works:

If I am not mistaken, with the code above, every slot address has two labels: SKU1 and SKU2.

In another code I would like to select the address of the slots and change the value of the labels that I have created above. I get the address of the slot from labels on my token that indicate the number of corridor, level, bay etc. and based on a condition I decide whether to assign the value "token.UDC.sku" to the slot label SKU1 or SKU2. If I am storing the first pallet, then the label SKU1 of that slot should be equal to the SKU of the pallet (token.UDC.sku). If I am storing the second pallet, I would like to set the value of the slot label SKU 2 equal to the SKU of the pallet (token.UDC.sku).

If I have three stored pallets I would need three slot labels (SKU1 SKU2 SKU3) and I would need to expand the code above to cover the condition if(token.cpal == 3). Since the number of pallets in the slot can vary, I wanted to automatize this system and I have tried to write the code below.

The problem is in the way I call the label of the slot. If I call it directly by its name (SKU1 or SKU2) it works but if I use the last code that I showed, it does not work because I cannot refer to the label of the slot address by using "concat...".

Does anybody know how to solve this problem and how to refer to a slot label without directly writing its name in the format .labelname?

Thank you so much for your help!

FlexSim 21.0.3
flexscriptstorage systemflexsim 21.0.3slot labelsaccessing labels
1616500117943.png (20.3 KiB)
1616500497510.png (16.6 KiB)
1616500631218.png (17.0 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

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Sonia A commented

object.labels["SKU"+mynum].value



· 5
5 |100000

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

Sonia A avatar image Sonia A commented ·

Hi Jason, Thank you for your answer!

Could I kindly ask you how you would put that part in the code I have shown above? I have tried this but it does not work.

I have also tried in this and it doesn't work either

Do you know how can I use what you suggested on a slot like in my case?

Thank you so much for your help, it is really appreaciated!

0 Likes 0 ·
1616504884607.png (13.6 KiB)
1616504937345.png (12.3 KiB)
1616505207994.png (12.4 KiB)
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Sonia A commented ·

You need to have the label on the slot first before you can use that expression.

For example - this code will put a label "SKU4" on every slot and set it to he index in the array of all slots.

Array slots=Storage.system.querySlots("");
for (int n=slots.length;n>0;n--){
    slots[n].labels.assert("SKU"+4);
    slots[n].labels["SKU"+4].value=n;
}


0 Likes 0 ·
Sonia A avatar image Sonia A Jason Lightfoot ♦♦ commented ·

Thank you a lot!

There is still something that I do not understand. In my code I have this part (picture) which already creates the labels on the slots. It creates them in the Storage System Properties, so theoretically I did have the labels on the slots before I used your expression. I can't use the expression Storage.system.getslot("string address") together with your suggestion (object.labels["SKU"+mynum].value ), even if I already have the labels on my slots. Do you have any idea why that is?

0 Likes 0 ·
1616512467332.png (90.1 KiB)
Show more comments