For loop running 3 times more than it should

Hi,
I have a for loop that loops from the size of an array to that size minus 1 through each row from a data table. The order is a for each loop, and off of loop body goes get data table rows and it grabs the row from the loop’s index and then creates a widget, however, it is calling the create widget node and everything after it 3 times more than it should and everything before that node and after the loop body pin is being called the correct number of 1 time in the loop.

Use breakpoints to debug what’s going on in your BPs.

I did. It runs starts with the pure function and everything past that is running 3 extra times. But before that it’s running only once like it should. It’s super weird.

Currently what’s happening is that the inventory size changes during the loop.
As you can see in Epic’ macro the LastIndex is not cached; meaning it is re-evaluated after each iteration.

meaning the extra 3 items are added somewhere after the beginning of the loop, somewhere, by something.

I just hardcoded a value in there and the same thing happens.

@Nebukam
I figured it out. I didn’t have a return node for a false case in my pure function. It technically should never fail but that is what was causing it to run extra times. I fixed it so now it won’t fail anyway but it’s good to know. Pure functions need return values when they exit.
image

@Zapking9224 wow this is such an obscure bug manifestation, I’ll definitely keep that in mind :sweat_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.