ForEachLoop in a Series - Completed Fires Every Loop

When you put 2 ForEachLoop in a Series the Completed on the second loop Fires Every Loop. This is terrible because any code that is connected to the completed keeps executing. Can you think of a workaround for this. I was going to use a delay but depending on how many objects the loops are processing the time could vary.

Thank you for any help you can give!

John

Hello! Why don’t you use the outer loop completed pin?

As AZTECCO mentioned, you might be interested in using the completed pin from the outer loop. The completed execution will fire for every time that specific loop node finishes the provided array data.

If you think of these as “outer” and “inner” loops, you can get a better understanding of what is going on. If the outer loop has 5 iterations, and the inner loop has 3, you’re doing whatever is in the inner loop 15 times.

The “completed” execution will fire once for every time the loop is executed. The outer loop will “complete” once per “L” press in your case, and the inner loop will complete once for every class in “Build List of Objects”.

Thank you guys for your replies! I should have had a better screenshot. I had loop body on the second loop going to a print string for testing. On the second loop, I guess that is called Outer I had the output hooked to the completed but what is happening is the code is executed over a hundred times. I then hooked to the first completed but it executes first and then starts the remaining code while the second loop is still running.

For a workaround I have attached a do once and a delay to the second loops completed pin and it works but it would be nice to know when both loops have completed so the rest of the code could start.

I hope I am explaining this right. It would seem that having 2 loops together and then having a completed ping that only executes once everything has completed would be basic. Or at least an option pin that says execute completed pin after each completed loop or execute completed pin after all loops are completed.

Thank you guys for your replies! I should have had a better screenshot. I had loop body on the second loop going to a print string for testing. On the second loop, I guess that is called Outer I had the output hooked to the completed but what is happening is the code is executed over a hundred times. I then hooked to the first completed but it executes first and then starts the remaining code while the second loop is still running.

For a workaround I have attached a do once and a delay to the second loops completed pin and it works but it would be nice to know when both loops have completed so the rest of the code could start.

I hope I am explaining this right. It would seem that having 2 loops together and then having a completed ping that only executes once everything has completed would be basic. Or at least an option pin that says execute completed pin after each completed loop or execute completed pin after all loops are completed.

Thank you guys for your replies! I should have had a better screenshot. I had loop body on the second loop going to a print string for testing. On the second loop, I guess that is called Outer I had the output hooked to the completed but what is happening is the code is executed over a hundred times. I then hooked to the first completed but it executes first and then starts the remaining code while the second loop is still running.

For a workaround I have attached a do once and a delay to the second loops completed pin and it works but it would be nice to know when both loops have completed so the rest of the code could start.

I hope I am explaining this right. It would seem that having 2 loops together and then having a completed ping that only executes once everything has completed would be basic. Or at least an option pin that says execute completed pin after each completed loop or execute completed pin after all loops are completed.

Just clarifying that the outer loop is the left one in your image. The inner loop is called so because it’s inside the other one. I can guarantee that when the outer (left) loop is completed, it will fire “complete” once.

It sounds like you want to use the left loop’s completed execution pin, as it “only executes once everything has completed”

Just finished testing and you guys were right, thank you so much! The first loops completed(outer) was the one that finished last. Also thank you for the information about inner and outer.