How to Access Class Properties in While Loop

" Maybe this is getting philosophical, but this is exactly what my code does.

(Okay, granted, exitLoop should initially be true)

  1. test() is called but exits immediately via return command. (same thing as doing the if in draw() but nicer imho)
  2. the loop is running, using the fact that draw() loops automatically (and calls test())
  3. when exitLoop is true again, test() is left immediately again"

Oh but no, this does not work. Have you tested it? It’s not philosophical, it just doesn’t work right.

I’ve spent days at this. I’d love it to work at you suggested. That in fact is the actual goal here.

Please input the code into a sketch and try it; I think you’ll see the issue…you get trapped into the loop and can’t get out, or you get into the loop and get out immediately.

Without a way to get the update to the isClicked property, there is no way to exit the loop. And with the other method, you never stay in the loop.

Well, - I could use a serial message to exit the loop, but I want the user to be able to click a button to get out of the loop.

Thank you Chrisir; maybe I’ve misunderstood your meaning but in my own testing it simply does not work as you are suggesting, wish it did.

1 Like