I already spent some thoughts on this, but it still needs some conceptional work.
E.g. there must be a way to terminate the loop from external (at least from the MIOS terminal) in case of a programming error (endless loop), otherwise the danger is too high that it won’t be possible to update the .NGR file via MIOS Filebrowser without unwanted side effects (e.g. application crash).
This is especially required for the case that the loop already starts in the DEFAULT.NGR file… etc…
Another potential issue is, that somebody could think, that a time consuming loop would run without side effects.
But currently we would have such effects, e.g. LCD output triggered by events won’t be handled as long as the .NGR script is executed.
Allowing more “multitasking” will require a lot of extensions, which I actually wanted to omit.
And btw.: I’m also pretty sure that the next request will be to allow some “simple” calculations, and variables, etc… things which will cause more effort at my side than initially planned.
Yes, I think I understand some of the potential for problematic side effects, complexities etc.
Without adding anything to the NGR capability a couple of methods come to mind:
Using (very?) long sections that poll the button/control state regularly to exit
Could there be a way of re-triggering the execution of a meta by another/or same control thus repeating a section but without the linguistic complexities?
Using (very?) long sections that poll the button/control state regularly to exit
yes, you can already do this
Could there be a way of re-triggering the execution of a meta by another/or same control thus repeating a section but without the linguistic complexities?
yes, this is already possible:
exec_meta RunSection:<section>
exit
As you can see, you are even able to start the .NCR script with different ^section values to execute different branches.
Btw.: meanwhile I got an idea how to deal with delays and SD Card access (just close the file, release the mutex, wait for x mS, take back the mutex, re-open the file).
In addition, a new Meta event makes sense which allows to terminate the execution (resp. clear an open request).
I will try this tomorrow.
But my statement is still true, that I don’t plan to add language extensions to control the program flow.
This is not a toggle mode button, you would have to specify button_mode=Toggle instead.
Then you can write (I haven’t tried it out, but I hope that you get the idea how it could work):
if ^section == 0
exit
endif
if ^section == 1
log "Section 1 called"
# do this
# and that
# maybe with some delays:
delay_ms 1000
# and finally:
if BUTTON:1 != 0
log "Retriggering section 1"
exec_meta RunSection:1
else
log "Finished."
endif
exit
endif
Btw.: meanwhile I got an idea how to deal with delays and SD Card access (just close the file, release the mutex, wait for x mS, take back the mutex, re-open the file).
I think this could be very helpful, as I’ve found the controls to be very slow to respond while a phrase is playing.