I have a for loop inside of while loop.when i press stop for while loop, i also would like to stop for loop.how can i solve this problem?thanks

i have a for loop inside of while loop.when i press stop for while loop, i also would like to stop for loop.how can i solve this problem?thanks

Hi fais,
Following through with what JB suggested. The steps involved in replacing the inner for loop with a while loop are outlined below.
You can replace the inner for loop with a while by doing the following.
1) Right-click of the for loop and select "Repalce" then navigate to the "while loop".
2) Make sure the tunnels you where indexing on with the for loop are still indexing.
3) Drop an "array size" node on your diagram. Wire the array that determines the number of iterations your for loop executes into this "array size".
4) Wire the output of the array size into the new while loop.
5) Set the condition terminal to "stop if true".
6)Drop an "OR" gate inside the while loop and wire its output to the while loops condition terminal.
7) C
reate a local of the boolean "stop" button, and wire it into one of the inputs of your OR gate. This will allow you to stop the inner loop.
8) Drop a "less than" node inside the inner while loop.
9) Wire your iteration count into the bottom input of the "less than".
10) Wire the count (see step 4 above) into the top input of the less than. This will stop the inner loop when ever the inner loop has processed the last element of your array.
Provided I have not mixed up my tops and bottoms this should accomplish the replacement.
I will let others explain how to takle this task using the "case solution".
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction

Similar Messages

Maybe you are looking for