question

Chandler avatar image
0 Likes"
Chandler asked Chandler answered

Array.append(int) in for loop, appends NULL values instead. User error or bug?

There is code in the assign labels area of my Source (in the arrivals tab) that assigns a patient type to tokens. (The label named type) I think the logic for selecting the type works fine, but I can't append an integer to an array for some reason and that's messing everything up.

Posting my model. Here's what it looks like. In the same loop I append to another array and that one works as expected. I am printing the values before and after each append and something here is just not working as expected.

Any help?

GSH_model_0-0-18-2_destroyedForTechSupport.fsm


HERE'S AN EXAMPLE OF THE OUTPUT CONSOLE:

flowStopsX as empty array:
Array[0]: {}

flowStopsPct as empty array:
Array[0]: {}

Loop number & value to append to flowStopsX:
1

flowStopsX with appended value:
Array[1]: {NULL}

flowStopsPct with appended value:
Array[1]: {41.65}

Loop number & value to append to flowStopsX:
2

flowStopsX with appended value:
Array[3]: {NULL,NULL,NULL}

flowStopsPct with appended value:
Array[2]: {41.65,41.08}

Loop number & value to append to flowStopsX:
7

flowStopsX with appended value:
Array[10]: {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}

flowStopsPct with appended value:
Array[3]: {41.65,41.08,4.80}

Loop number & value to append to flowStopsX:
8

flowStopsX with appended value:
Array[18]: {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}

flowStopsPct with appended value:
Array[4]: {41.65,41.08,4.80,1.92}

Loop number & value to append to flowStopsX:
9

flowStopsX with appended value:
Array[27]: {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}

flowStopsPct with appended value:
Array[5]: {41.65,41.08,4.80,1.92,1.92}

Loop number & value to append to flowStopsX:
10

flowStopsX with appended value:
Array[37]: {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}

flowStopsPct with appended value:
Array[6]: {41.65,41.08,4.80,1.92,1.92,0.96}

Loop number & value to append to flowStopsX:
11

flowStopsX with appended value:
Array[48]: {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}

flowStopsPct with appended value:
Array[7]: {41.65,41.08,4.80,1.92,1.92,0.96,0.96}

Loop number & value to append to flowStopsX:
12

flowStopsX with appended value:
Array[60]: {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}

flowStopsPct with appended value:
Array[8]: {41.65,41.08,4.80,1.92,1.92,0.96,0.96,0.96}

Loop number & value to append to flowStopsX:
13

flowStopsX with appended value:
Array[73]: {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}

flowStopsPct with appended value:
Array[9]: {41.65,41.08,4.80,1.92,1.92,0.96,0.96,0.96,0.96}

Loop number & value to append to flowStopsX:
14

flowStopsX with appended value:
Array[87]: {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}

flowStopsPct with appended value:
Array[10]: {41.65,41.08,4.80,1.92,1.92,0.96,0.96,0.96,0.96,4.80}

flowStopsPct as modified list of ranges:
Array[10]: {41.65,82.74,87.53,89.45,91.37,92.33,93.29,94.25,95.20,100}

END OF SCRIPT FOR THIS TOKEN

FlexSim 23.1.2
arrayscriptingappend
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

Chandler avatar image
0 Likes"
Chandler answered

Answered my own question...

I should be using Array.push for an integer or double.

Array.append appends another array.

5 |100000

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