?????
You test the key and do whatever you want
Here is an example that prompts until you
press "Q"
Here is an example that prompts until you
press "Q"
Code: Select all
CLS
DO
PRINT "Press key: ";
DO: k$ = INKEY$: LOOP WHILE k$ = ""
PRINT k$
IF UCASE$(k$) = "Q" THEN END
LOOP
My way:
Code: Select all
CLS
DO
PRINT "Press key: ";
DO: k$ = INKEY$: LOOP WHILE k$ = ""
PRINT k$
LOOP UNTIL UCASE$(k$) = "Q"
END
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
Hmmmmmmm
Mac you both used END instead of SYSTEM too. Bad boys LOL
Ted
Ted
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
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
Re: Hmmmmmmm
Good catch, but I had a reason: focus on how to capture key, not how to terminate a program.burger2227 wrote:Mac you both used END instead of SYSTEM too. Bad boys LOL
Ted
Code: Select all
CLS
PRINT "Press ESC to exit program, 'T' to print time"
DO
PRINT : PRINT "Press key: ";
DO: k$ = INKEY$: LOOP WHILE k$ = ""
IF k$ = CHR$(27) THEN EXIT DO ELSE PRINT k$
IF UCASE$(k$) = "T" THEN PRINT TIME$
LOOP
PRINT : PRINT
LINE INPUT "Press ENTER"; e$
SYSTEM
Also shows that ESC is a good way out rather than bogus Q.
Mac
Guess I've got no excuse for my mistake. I've been programming in Creative BASIC lately, very similar to QB/FB in console mode.