Both Example has the 'Exit' operator, but it work differently... why...???
I feel a bit strange at the 'Exit' operator in the Example 2..
My understanding, In the example 1 and 2, the m3 For loop shouldn't be working with their condition because of the 'Exit' operator will end the innermost loop but the Example 2 works why?
Anyone could help to explain...???
For the Example 1,
The IF condition's M200 always True and as a result
Both Example has the 'Exit' operator, but it work differently... why...???
I feel a bit strange at the 'Exit' operator in the Example 2..
My understanding, In the example 1 and 2, the m3 For loop shouldn't be working with their condition because of the 'Exit' operator will end the innermost loop but the Example 2 works why?
Anyone could help to explain...???
For the Example 1,
The IF condition's M200 always True and as a result
M3 got 0 value.(it didn't loop at all).
For The Example 2,
The IF condition's when M1=M3 and as a result
M3 got 5.
for_test_with_exit2_ok.pro [23.66 KiB]
You did 'Single cycle' in the debugger, therefore you saw only the final results β after the last iteration.
In details:
Inside 1-st iteration m1 = m3 = 0 β EXIT
β¦
Inside 6-st iteration m1=5, m3 = 0 β m3 runs from 0 to 5
Do try to use a breakpoint and you will catch it.
and please do not exit inside a loop as the stack will not be correct.
do the question before the loop or after it.