Re: How can I assign the interrupt action to a function key in 4GL?
Posted in 1992
Quoting Marco Penengo... > As the title states, I would like to bind the Control-C interrupt > action to function key F5 and the Accept action to function key F9. > I have managed to bind the Accept option to Control-B but doing > OPTIONS ACCEPT KEY F9 does not work; I just get a beep. > example: > ~~~~~~~~ > : > : > OPTIONS ACCEPT KEY F9 > : > OPEN WINDOW wind001 AT 1,1 WITH FORM "stabcr01" > OPEN FORM screen0 FROM "stabcr01" > DISPLAY FORM screen0 > CALL SET_COUNT(jrectrov) > DISPLAY ARRAY wscanrec TO screen0.* > LET jrecsele = ARR_CURR() > : > : > In this case I would like to choose one record using function key F9 > instead of ESC. This is what I would do... : : OPTIONS ACCEPT KEY CONTROL-Q # Disable ESC key for ACCEPT # INTERRUPT can't be disabled : OPEN WINDOW wind001 AT 1,1 WITH FORM "stabcr01" OPEN FORM screen0 FROM "stabcr01" DISPLAY FORM screen0 LET int_flag = FALSE # Set int_flag to known state CALL SET_COUNT(jrectrov) DISPLAY ARRAY wscanrec TO screen0.* ON KEY (INTERRUPT) LET int_flag = FALSE # This ignores CTRL-C ON KEY (F5) LET int_flag = TRUE # This does the same thing as EXIT DISPLAY # though CTRL-C was hit ON KEY (F9) EXIT DISPLAY # This works like ESC END DISPLAY LET jrecsele = ARR_CURR() : : Now, what did I do? I disabled the ACCEPT key by setting it to CTRL-Q. The shell/stty/whatever will snag CTRL-Q long before 4GL ever sees it. INTERRUPT can't be disabled because that's done at the shell/stty/whatever level. I turned the int_flag off so it can be set/checked later. When F5 is hit, I set the int_flag and exit the DISPLAY ARRAY... Voila, an interrupt has just happened. When F9 is hit I just exit. Checking the int_flag will tell you whether the F5, or F9 key was hit. If you need to know EXACTLY which key was hit, use fgl_lastkey(). Now for the plug :-) Don't have fgl_lastkey() ??? Grab db4glgen-3.7 and use it's fgl_lastkey(). DAS -- David A. Snyder @ Snide Inc. - Folcroft, PA Current Release is db4glgen-3.7 UUCP: ..!uunet!das13!dave INTERNET: dave.snyder@snide.com