I understand this loop doesn't work as I could expect in another languages, but i think should be a simple way to solve instead to use a clock or temporizer. Maybe if could be any way to run an event from a block, or force to actualize the GUI or something similar?
I appreciate the answer, but I was thinking in a solution like ‘Call Button.Click’ from the program, or better yet 'Call Button.”Run”’ or similar new option to allow run an event or pseudoevent from the program. This wouldn't break any event rule, but it would make programming substantially easier and more intuitive.
Thank you, I appreciate the answers. I understand the proposed is the better way nowadays to solve this kind of situations. Maybe in the future the MIT App Inventor team could include some new feature that allow, as I said before, a solution like ‘Call Button.Click’ from the program, or better yet 'Call Button.”Run”’ or similar new option to allow run an event or pseudoevent from the program. This wouldn't break any event rule, but it would make programming substantially easier and more intuitive, allowing to obtain a simple and clear program similar to this:
The long term solution that needs to be implemented is a technique called continuation passing style. However, getting this right is very tricky and we don't want to accidentally introduce bugs into people's code that they can't fix because the change results in different code output than App Inventor currently produces. Continuation passing would allow different events to interleave by not blocking the UI thread while execution occurs. The lack of continuation passing right now is the main reason why the use of the Clock is necessary for loops that run over time and the reason why we don't have a wait block unlike other blocks based languages (e.g., Scratch).