For Loops and Functions

Hi Guys

Just a quick question. Do For Loops not work inside of functions?

I have a ReverseForEachLoop currently inside a Macro which modifies an array depending on a value. It works perfectly fine.

However, I am trying to turn my Macros into Functions, and when I place the exact same code into a Function, it doesn’t seem to work. My Macro/Function also contains a branch and depending on this, the array is modified or not.

It’s like my Loop code is ignored when I put it into a function.

So is it not possible? I could leave it as a macro, but it is something that gets used quite often and thought I’d be better of with a function.

Thanks.

What engine version are you on? I’ve noticed similar behavior in 4.19.2 with loops inside of functions that don’t pass the input by ref. Give that a shot if your relying on input pins.

I’m on 4.20.3 - I’m not using any input pins. All my loop is doing is going through my array and removing the index of any empty slots.