is there a hot key to break an endless loop which is running

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
gremlin4
Newbie
Posts: 9
Joined: Sun Jun 29, 2014 9:16 am

is there a hot key to break an endless loop which is running

Post by gremlin4 »

OK I'm a bit rusty, haven't used qb seriously for about 10 years and I've just turned 80
My question is:- If, in programming in Windows XP and QB, if I inadvertently insert an endless loop into my code and run it before I find out that it is endless, what can I do to stop execution WITHOUT losing the program status wot I've got up till then?
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Re: is there a hot key to break an endless loop which is run

Post by burger2227 »

Just use Ctrl + break to stop the program. Closing the window may close the QB IDE.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
gremlin4
Newbie
Posts: 9
Joined: Sun Jun 29, 2014 9:16 am

Re: is there a hot key to break an endless loop which is run

Post by gremlin4 »

OK, thanks a million, but, my keyboard (106 keys? seems a lot but i counted them twice)was made in china, has keys labelled in a sort of spanish shorthand.
CTRL I can find, but 'break' not.
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Re: is there a hot key to break an endless loop which is run

Post by burger2227 »

LOL, my Dell keyboard doesn't either! Look for the Pause/Break button next to Scroll Lock.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
gremlin4
Newbie
Posts: 9
Joined: Sun Jun 29, 2014 9:16 am

Re: is there a hot key to break an endless loop which is run

Post by gremlin4 »

Bingo! I'm much indebted
ed
gremlin4
Newbie
Posts: 9
Joined: Sun Jun 29, 2014 9:16 am

Re: is there a hot key to break an endless loop which is run

Post by gremlin4 »

This page doesn't give me the option to unsubscribe
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Re: is there a hot key to break an endless loop which is run

Post by burger2227 »

Unsubscribe from what?

Uncheck Notify me when a reply is posted box if you don't want notifications.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
User avatar
michealey
Coder
Posts: 11
Joined: Sun Dec 03, 2006 8:31 pm
Location: Florida
Contact:

Re: is there a hot key to break an endless loop which is run

Post by michealey »

One point I would like to append to this thread - is that if you are running QBASIC in DOSbox, the CTRL+Break does NOT work. However, there is a simple work-a-round. You can simply use CTRL+SCROLL LOCK - this performs the exact same function. :)

FYI
W6UHQ
Newbie
Posts: 1
Joined: Sat Apr 08, 2017 7:51 pm

Re: is there a hot key to break an endless loop which is running

Post by W6UHQ »

Hey, help another old guy out.. I'm with Gremlin4.... I've been in the trenches with COBOL, Assembler, FORTRAN etc.... and just a bit
of application programming with BASIC.... and I always (and probably always will) find that I have built me a cute little, tight, endless loop.
Most notable was going to top of page on a 1403 printer doing statements... ohhh, that was a fast printer... my question (beating a dead horse),
how can I get a QB64 program running under Win 10 to terminate... CTRL BREAK doesn't work, Control Scroll Lock doesn't work... (no such key on my Logitech K360 wireless keyboard).... however, the Windows famous "Nuclear Option" of terminating a running program works... a bit
of overkill.... was there updates on this subject?

Regards
Dennis/W6UHQ
Herald, CA
mikefromca
Coder
Posts: 41
Joined: Wed Oct 16, 2019 11:28 am

Re: is there a hot key to break an endless loop which is running

Post by mikefromca »

you could try CTRL+C but then its like CTRL+BREAK but you'd lose status.

In a Qbasic program you need to modify your endless loop from:

Code: Select all

Do
**insert whatever
Loop
To:

Code: Select all

Do
**insert whatever
if inkey$="X" then 
reset
system
end if
**insert whatever
Loop
but replace "X" with the actual key or scan code you want to use to force an exit out of your endless loop. I use "reset" and "system" instead of simply an "end" because "reset" closes all open files and "system" is a better way for me to end programs.

I know its not the most wonderful way to end a program but if your endless loop is rather complex, its a quick and dirty way to go
Post Reply