How to organize and pull single items from a list

How to organize and pull single items from a list

sonia_a
Not applicable
19 Views
6 Replies
Message 1 of 7

How to organize and pull single items from a list

sonia_a
Not applicable

[ FlexSim 21.0.0 ]

Hello everybody!

I am trying to build a model focused on warehouse systems. In my warehouse, I have some drive-in racks with corridors, levels and bays. At every level, bay and corridor there is a control point on an AGV network. I would like some pallets (sku=1) to be stored as close as possible to a specific control point (called CP1). I have thought to put all the Control points of the rack (which are indications of the address of slots in the racks) in a list and to calculate for every control point the distance to CP1. I have filled the list as you can see in the code below.

37501-1615191484448.png

I have then calculated the distance in another custom code and this is the result. As you can see the CPs in the list are ordered based on the way they have been pushed in the list. I would like to have the CPs in the list ordered by increasing distance (from lowest to highest). How do I put the CPs with the lowest distance in the first position? If I can do that, how can I pull the first CP from the list?

37498-1615192225109.png

Maybe I am approaching the problem in a weird way but my end goal is to pull from that list, one CP at a time, the CPs with the lowest distance (and of course have them removed from the list after I have pulled them). Does anyone have ideas on the right commands to use to achieve that?

To be extra clear, if we look at the list above, I would like to pull CP11011, save this address in a variable, do some other things and then remove CP11011 from the list. I would then pull CP11021, save the address and remove CP11021 from the list. I would then like to pull CP12011 save this address and remove it from the list, and so on following the distance values from lowest to highest.

I have tried to pull items in this way but it does not work, I am doing something wrong:

Variant ind_CP = List("CP list").pull("ORDER BY distance ASC");

Thank you so much for your help!


0 Likes
Accepted solutions (1)
20 Views
6 Replies
Replies (6)
Message 2 of 7

joerg_vogel_HsH
Mentor
Mentor
Accepted solution

FlexScript Class Reference in Manual:

List.pull

List.PullResult

List - functional concepts

0 Likes
Message 3 of 7

sonia_a
Not applicable

Thank you, I have managed to pull items from the list in this way:

Variant ind_CP = List("CP list").pull("ORDER BY distance ASC",1,1);

Is there a way to copy the item value with the lowest distance from the list into a variable? When using List.pull() the item is deleted from the list but I don't want to lose that information since I need to compare the item value with something else before removing it from the list.

Thank you for your help!

0 Likes
Message 4 of 7

fapicella
Enthusiast
Enthusiast

Hi,

as you write is good. Flexsim save in the local variable (in your case ind_CP) the information of what item you are pulled. If you want to access this variable all the time, you can save it on a GlobalVariable as in the picture below

37524-1615203803223.png

0 Likes
Message 5 of 7

joerg_vogel_HsH
Mentor
Mentor

A list pull method does not store any field values. If you need the field values then you can query the list as a table. You do a table.query and then you pull the value from the list.

37525-77ebb1a1-61a0-487d-b557-8068c0106509.jpeg

0 Likes
Message 6 of 7

Ben_WilsonADSK
Community Manager
Community Manager

Hi @Sonia A, was Sonia A's or Jörg Vogel's answer helpful? If so, please click the red "Accept" button at the bottom of one of their answers. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes
Message 7 of 7

sonia_a
Not applicable

Thank you for your help!

0 Likes