Normally, once a Forth process is running there is no way to stop it without going to the Index and KILLing CamelForth. We provide two words to allow the ESC key to be used to abort a process (this of course is only effective when your process examines the keyboard for input - if not, a reset is your only recourse!).
The most important word is OS_ESC which is a straight implementation of the OZ call of the same name. This word takes a reason code from top of stack and leaves a result code, which is the value in the AF register pair. Normally we can ignore this, but see the Developers' Notes if you want full information.
The important phrases to use are 5 OS_ESC DROP (which turns ESC detection on), 6 OS_ESC DROP (which turns it off again) and 1 OS_ESC DROP (which acknowledges an ESC error code).
When escape detection is on, any time one of the input words detects an RC_ESC error condition, (RC_ESC) is executed. Normally, this is set to the word ESCAPE which acknowledges the error code and then ABORTs with a message, but you can change this if you want a different action.
Escape detection is normally off, so try this by typing 5 OS_ESC DROP and then pressing ESC.
IMPORTANT!! If you replace the normal (RC_ESC) word, the first thing your new word must do is acknowledge the error code with 1 OS_ESC DROP. If you don't do this, then your application will continue to receive escape errors indefinitely!
More about CamelForth
Back to the Z88 home page