You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Say I want to interrupt a loop with a key press, diverting to some other routine, which is possible with something like
DEFINEKEY ASC("p"), mySub
in the initialisation section. Now, when I tap the 'p' key, it diverts to mySub as expected.
I can exit the subroutine in the usual ways. I can PAUSE (without argument) and hit another key to continue to END (the sub), but I can't hit 'p', or it diverts immediately to the sub again. It would be neat if I could return to the main loop by a second press of 'p'. Even more of a problem is that no press of 'p' doesn't get grabbed by the interrupt, so you can't pause the loop and ask for input, or if you do and enter a 'p', you're back to the start of the subroutine.
What's needed is an UNDEFINEKEY asc("p"), or DEFINEKEY asc("p"), ""
but those don't seem to work.
I've tried a few possible solutions, including starting the subroutine with a new definition to a dummy subroutine, but it seems to be ignored (although you can define other keys inside a sub). It seems once defined, that's it, it stays defined.
I thought I had it when I made the pause routine just toggle a variable, running, testing for running=0 in the main loop and diverting to a second subroutine for the inputs, etc. This avoids the immediate interruption of input, but control appears still to be diverting to the toggle subroutine each time a p is pressed, so 2 (or any even number of) presses and when I finish input, it pauses again, any odd number in the input string and running is true again, so it's still not a solution.
Any thoughts...apart from maybe just using single key presses to interrupt the loop that aren't going to be used elsewhere, but there's not many to choose from. I can pause with a backspace, say, and exit the mySub with ESC."
The text was updated successfully, but these errors were encountered:
https://www.syntaxbomb.com/index.php/topic,7519.0.html
"Say I want to interrupt a loop with a key press, diverting to some other routine, which is possible with something like
DEFINEKEY ASC("p"), mySub
in the initialisation section. Now, when I tap the 'p' key, it diverts to mySub as expected.
I can exit the subroutine in the usual ways. I can PAUSE (without argument) and hit another key to continue to END (the sub), but I can't hit 'p', or it diverts immediately to the sub again. It would be neat if I could return to the main loop by a second press of 'p'. Even more of a problem is that no press of 'p' doesn't get grabbed by the interrupt, so you can't pause the loop and ask for input, or if you do and enter a 'p', you're back to the start of the subroutine.
What's needed is an UNDEFINEKEY asc("p"), or DEFINEKEY asc("p"), ""
but those don't seem to work.
I've tried a few possible solutions, including starting the subroutine with a new definition to a dummy subroutine, but it seems to be ignored (although you can define other keys inside a sub). It seems once defined, that's it, it stays defined.
I thought I had it when I made the pause routine just toggle a variable, running, testing for running=0 in the main loop and diverting to a second subroutine for the inputs, etc. This avoids the immediate interruption of input, but control appears still to be diverting to the toggle subroutine each time a p is pressed, so 2 (or any even number of) presses and when I finish input, it pauses again, any odd number in the input string and running is true again, so it's still not a solution.
Any thoughts...apart from maybe just using single key presses to interrupt the loop that aren't going to be used elsewhere, but there's not many to choose from. I can pause with a backspace, say, and exit the mySub with ESC."
The text was updated successfully, but these errors were encountered: