Sequence + Foreach with Control - sequential or parallel execution

I’m not sure if that’s a bug or a feature …

I wanted to use Sequence + Foreach with a Control as a variable, used in each “foreach”. I simplified my case because it’s a very complex formula.

So I have a button with this formula :

Runactions(SetControlValue(variable, 0), Sequence(1, 5).ForEach(SetControlValue(variable, variable+CurrentValue)))

I expected to have after a click : 1+2+3+4+5 = 15 in the control “variable” but I had 5. As if every foreach was executed at the same time, so without considering the new value of “variable”.

I found a workaround :

Runactions(SetControlValue(variable, 0), Sequence(1, 5).ForEach(RunActions(SetControlValue(variable, variable+CurrentValue))))

I think of it as an undocumented feature.
RunActions() updates values between interactions but it slows down the operation.

Yes, this is known and by design (although yeah, not really documented)

Thanks for your answers :slight_smile:
Now, I know !