Page 1 of 1

safe break out of a while loop

PostPosted: Sun Nov 05, 2017 6:36 pm
by Battwell
what is the safest way of breaking out of a while loop
ie in case of an input led not being found when in while loop

i had a case today where my macro wasnt be able to be stopped
i have a wait 100 in it so it doesnt over run

Re: safe break out of a while loop

PostPosted: Sun Nov 05, 2017 7:39 pm
by Robertspark
What was the test?

Code extract of while + explanation

One way to do it is define a counter / timer and run that inside the while loop then return after the duration.

Really you don't want to run too many while loops unless you are waiting for something certain to happen.

Unless it's something like while is loading / stopped I try to stay away from it.... All depends upon what you want to do with it as there may be another way

Re: safe break out of a while loop

PostPosted: Sun Nov 05, 2017 7:46 pm
by Robertspark

Re: safe break out of a while loop

PostPosted: Sun Nov 05, 2017 9:46 pm
by Dan911
while (bool == true)