Array Index from Array Value

Array Index from Array Value

zixuan_xiong
Not applicable
541 Views
2 Replies
Message 1 of 3

Array Index from Array Value

zixuan_xiong
Not applicable

[ FlexSim 7.7.4 ]

How can I get the index number in an array based on the array value?

For example the array label showing below. Is there a function can search token id: 1050 inside a array and return the index value 2?

201-untitled.png

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

legrand_gold
Not applicable
Accepted solution

Put the following in the Value field of an Assign Labels activity:

treenodearray pallets = getlabel(token, "pallet");
return findmatch(arraysize(pallets), gettokenid(pallets[count]) == 1050);

You can read more about findmatch in the user manual. Basically, it is a for loop that returns the count where the second parameter was true. In this case, it returns the count where it found token ID 1050.

Message 3 of 3

zixuan_xiong
Not applicable

Thank you! That's the function I'm looking for.

0 Likes