Make it stop: (ctl + break doesnt work)
Moderators:Administrator, Global Moderator
-
- Newbie
- Posts:8
- Joined:Thu Jul 19, 2007 12:36 am
- Location:Davis, CA
Does anyone know an alternative way to make a QB program stop executing, besides control - break? It's not working for me
--running QB 4.5 under dosbox 0.63 and windows 2000.
--running QB 4.5 under dosbox 0.63 and windows 2000.
Right, Mac. I learned some time ago that one should not expect anyone to answer back. If they do, that's great! If they don't, well, I was now expecting them to answer. Seems the last occurs with some frequency, in almost all forums. That's just pwople are, and, we can't live trying to change them. At least, not me!
Your suggestion, Mad, sounds reasonable, but, when one is running a program, and has the problem, that's when we want to be able to stop it. I have had problems of that nature often, and the Ctrl+Break, followed by Esc, has done the trick for me, so, I recommend it as a general method.
Your suggestion, Mad, sounds reasonable, but, when one is running a program, and has the problem, that's when we want to be able to stop it. I have had problems of that nature often, and the Ctrl+Break, followed by Esc, has done the trick for me, so, I recommend it as a general method.
Ralph. Running QuickBASIC Version 4.5, Windows XP Home Edition, Version 2002, Service Pack 2, and HP LaserJet 4L printer.
Here’s a snippet. Pressing F1 will generate an interrupt diverting the program to the subroutine ‘trapkey’.
‘put this at the start of your program
ON KEY(1) GOSUB trapkey
KEY(1) ON
‘and this at the end
trapkey:
END
If you want to, you can trap the Escape key instead, but you have to define KEY(15) first. The routine then becomes
KEY 15, CHR$(0) + CHR$(1)
ON KEY (15) GOSUB trapkey
KEY (15) ON
‘put this at the start of your program
ON KEY(1) GOSUB trapkey
KEY(1) ON
‘and this at the end
trapkey:
END
If you want to, you can trap the Escape key instead, but you have to define KEY(15) first. The routine then becomes
KEY 15, CHR$(0) + CHR$(1)
ON KEY (15) GOSUB trapkey
KEY (15) ON
Here is the list:
Key(1) to Key(10) = F1 to F10 function keys
Key (11) Up arrow
Key (12) Left arrow
Key(13) Right arrow
Key(14) Down arrow
Key (15) to Key(25) User defined keys
Key(30) F11 function key
Key(31) F12 function key
For user defined, the two characters are 'shiftcode' and 'keyboard scan code'. Single key presses have shiftcode = 0, so
Escape = 0 + 1
Spacebar = 0 + 57
etc.
There are other shiftcodes for combinations like Shift-Spacebar
Key(1) to Key(10) = F1 to F10 function keys
Key (11) Up arrow
Key (12) Left arrow
Key(13) Right arrow
Key(14) Down arrow
Key (15) to Key(25) User defined keys
Key(30) F11 function key
Key(31) F12 function key
For user defined, the two characters are 'shiftcode' and 'keyboard scan code'. Single key presses have shiftcode = 0, so
Escape = 0 + 1
Spacebar = 0 + 57
etc.
There are other shiftcodes for combinations like Shift-Spacebar
True. ON KEY effectively insertsRalph wrote:Sounds much better than Mac's proposal.
IF INKEY$ = CHR$(27) THEN GOSUB xxx
after EVERY instruction, without the overhead of actually doing that.
Much better if you have no idea why you are stuck.
But usually you know it is in a certain DO-loop and can insert the single IF INKEY$ command right after the DO quite easily without messing with the often-unfamiliar ON KEY stuff.
By the way, I am unable to test the ESC hint because ctrl-break works nicely on WindowsNT. But I will remember it if I am stuck on some other machine. Good info.
Mac
Mac
The QBasic Forum
http://www.network54.com/Forum/13959
The QBasic Forum
http://www.network54.com/Forum/13959
It’s not just to get out of a fault condition that requires a quick getout from a program. Several years ago I did a suite of programs in QuickBasic for a company that did electrical maintenance work – mainly for the local council. The company had a receptionist, general and accounts staff and 6 electricians.
The program contained databases for spares and work-in-hand status. The drill was that the receptionist would take jobs over the phone at any time and prioritise them on the database. Each electrician had access to this list of jobs to be done in order of priority. When free, he took the next job and noted in the database that he had done so. That way it was possible for the next man to take the next job with no overlap.
When he had finished he entered details of spares and labour and mark the job as done and ready for invoicing. Accounts staff routinely searched for jobs completed and invoiced them. Nine people all had access to the program and used it for different purposes. That meant that the program was driven by a succession of menus with programs being chained from one to another.
When any user had finished with the program it would have been tedious to backtrack all the way back through the menu and chained programs to the start. It was far easier to do one On KEY instruction in each program that chained back to the main one, ready for the next user.
The program contained databases for spares and work-in-hand status. The drill was that the receptionist would take jobs over the phone at any time and prioritise them on the database. Each electrician had access to this list of jobs to be done in order of priority. When free, he took the next job and noted in the database that he had done so. That way it was possible for the next man to take the next job with no overlap.
When he had finished he entered details of spares and labour and mark the job as done and ready for invoicing. Accounts staff routinely searched for jobs completed and invoiced them. Nine people all had access to the program and used it for different purposes. That meant that the program was driven by a succession of menus with programs being chained from one to another.
When any user had finished with the program it would have been tedious to backtrack all the way back through the menu and chained programs to the start. It was far easier to do one On KEY instruction in each program that chained back to the main one, ready for the next user.
Good point.
If the program primarily gets user input via INKEY$ then something like this is good, too:
Mac
If the program primarily gets user input via INKEY$ then something like this is good, too:
Code: Select all
DECLARE FUNCTION zkey$ ()
DO
k$ = zkey
PRINT k$;
LOOP
FUNCTION zkey$
DO: k$ = INKEY$: LOOP WHILE k$ = ""
IF k$ = CHR$(27) THEN PRINT : SYSTEM
zkey$ = k$
END FUNCTION
Mac
The QBasic Forum
http://www.network54.com/Forum/13959
The QBasic Forum
http://www.network54.com/Forum/13959