Skip to content

No undo for DEFINEKEY #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chrisws opened this issue Mar 24, 2020 · 0 comments
Closed

No undo for DEFINEKEY #92

chrisws opened this issue Mar 24, 2020 · 0 comments
Assignees
Milestone

Comments

@chrisws
Copy link
Contributor

chrisws commented Mar 24, 2020

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."

@chrisws chrisws self-assigned this Apr 5, 2020
@chrisws chrisws added this to the 0.12.19 milestone Apr 5, 2020
chrisws added a commit to chrisws/SmallBASIC that referenced this issue Apr 6, 2020
chrisws added a commit to chrisws/SmallBASIC that referenced this issue Apr 6, 2020
chrisws added a commit to chrisws/SmallBASIC that referenced this issue May 8, 2020
chrisws added a commit to chrisws/SmallBASIC that referenced this issue May 8, 2020
@chrisws chrisws mentioned this issue Jul 16, 2020
@chrisws chrisws closed this as completed Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant