question

Kathryn McNeal avatar image
0 Likes"
Kathryn McNeal asked Kathryn McNeal commented

using concat to identify the name of an array

I'm trying to create a single process flow that will work for any number of parts. The arrays are named "ArrayA", "ArrayB", "ArrayC", etc. I'm storing the letter of the part (A, B, or C) in a variable named "partName", and then trying to use concat("Array", partName)[1] to look up the first value in ArrayA (or whichever one is being looked at). I'm getting an error because it isn't recognizing the concatenation as the name of an array. Is there a way around this in flexscript?

FlexSim 16.1.2
arrayconcat
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

Joerg Vogel avatar image
3 Likes"
Joerg Vogel answered Kathryn McNeal commented

I have build a global variable array named testA. I print the values of testA[1]..testA[n] to the output console. This is adapted from this answer from @phil.bobo.

I have put this following code into the OnEntry trigger of a queue. The Item's name is always "A". But you can change it if you like.

string val = concat("test",getname(item),"[",numtostring(getinput(current)),"]");
pr();pf(executestring(val));
	
· 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.

Kathryn McNeal avatar image Kathryn McNeal commented ·

That's exactly what I needed, thanks!

1 Like 1 ·