Hi,
My first qbasic program, and I'm chuffed.
In two or three places I use coding like:-
C$=inkey$
do
loop until c$>< ""
looking for a Y for yes, N for no or E for exit etc.
problem I got is if user enters yes not just Y the next bit of similar coding seems to pick up the E of yes and thingy up the whole thing by exiting.
I would prefer to use inkey$ rather than input$.
Is there a way of clearing the buffer just before the inkey$ statement.
Thanks for your time guys.
MikeG
Real newbie question
Moderators:Administrator, Global Moderator
-
- QBasic God
- Posts:166
- Joined:Tue Mar 25, 2003 12:45 am
- Location:U.S.A.
- Contact:
Hi there...
This is the problem...
loop until c$>< ""
That will exit the loop if any key is pressed...
Also, there is no need to clear the buffer each time through the loop because the next call to inkey$ replaces what's stored in the buffer C$.
Another thing...
You need to call INKEY$ from inside the DO...LOOP statement block.
This is one solution...
The UCASE$ function returns UpperCASE characters no matter what. In contrast, the LCASE$ function returns LowerCASE characters.
Here's an example...
Hopefully this clears things up a bit for you. ;D
loop until c$>< ""
That will exit the loop if any key is pressed...
Also, there is no need to clear the buffer each time through the loop because the next call to inkey$ replaces what's stored in the buffer C$.
Another thing...
You need to call INKEY$ from inside the DO...LOOP statement block.
This is one solution...
Code: Select all
DO
C$ = UCASE$(INKEY$ )
LOOP UNTIL C$ = "E"
Here's an example...
Code: Select all
MyName$ = "dave"
PRINT UCASE$(MyName$)
Come check out [url=http://www.freebasic.net/forum/index.php]FreeBASIC[/url]. The syntax is based on QuickBasic, but it expands to use pointers, operator overloading, etc... The list goes on and on!