clearing the keyboard buffer 
Author Message
 clearing the keyboard buffer


Quote:
> How do you clear the keyboard buffer in QB 4.5 ??

Dunno if there's a better way, but why not

DO
LOOP UNTIL INKEY$ = ""

The Cookie Monster



Mon, 31 Mar 1997 13:41:06 GMT  
 clearing the keyboard buffer

Quote:
Britton) writes:

<How to clear the keyboard buffer

while inkey$<>""
wend

Bob



Mon, 31 Mar 1997 13:37:05 GMT  
 clearing the keyboard buffer

(James S. Britton) says:

Quote:

>How do you clear the keyboard buffer in QB 4.5 ??

This Statement will work nicely:

        while inkey$ <> "" : wend

Regards,
Anders



Sun, 30 Mar 1997 21:50:50 GMT  
 clearing the keyboard buffer
How do you clear the keyboard buffer in QB 4.5 ??


Sun, 30 Mar 1997 15:20:07 GMT  
 clearing the keyboard buffer

: This Statement will work nicely:
:       while inkey$ <> "" : wend

For perfectionist optimization:

  DO: LOOP UNTIL LEN(INKEY$)

Integer comparisons are always faster than string comparisons, logically.



Tue, 01 Apr 1997 05:26:07 GMT  
 clearing the keyboard buffer

Quote:

> (James S. Britton) says:

> >How do you clear the keyboard buffer in QB 4.5 ??
> This Statement will work nicely:
>    while inkey$ <> "" : wend

And this statement will work just as nicely, is faster, and generates
less compiled code:

        DO: LOOP WHILE LEN(INKEY$)

:-)

(Yeah, I know, optimizing a keyboard-clearing loop probably won't
make a whole lot of difference.  It's just a habit I've gotten
into.  Checking for a zero/nonzero string length in QuickBASIC is
always faster than performing a comparison to a null string, and
the jumps in an empty DO:WHILE loop are more efficient than
the jumps in an empty WHILE:WEND.)

---
Glen Blankenship




Tue, 01 Apr 1997 03:12:38 GMT  
 clearing the keyboard buffer

-> How do you clear the keyboard buffer in QB 4.5 ??

   Well, I know there's a way to do it using a poke or two, but this is
one way of doing it:

do
   a$ = inkey$
loop until a$ = ""

   So this will keep reading characters until there is no more
characters to read from the buffer.

.--------------------------------------------------------------------.
| Jeff Culler                     Canada Remote Systems (CRS Online) |

`--------------------------------------------------------------------'



Fri, 04 Apr 1997 06:00:00 GMT  
 clearing the keyboard buffer

Quote:
(Jeff Culler) writes:

I've used
   DEF SEG = &H40  ' point head to tail to empty keyboard
   POKE &H1A, PEEK(&H1C)

Hope this helps :)
mike



Fri, 04 Apr 1997 22:30:05 GMT  
 clearing the keyboard buffer


Quote:
>How do you clear the keyboard buffer in QB 4.5 ??

        You can do this :

        do
        loop until INKEY$ = ""

Eric



Fri, 04 Apr 1997 23:35:08 GMT  
 clearing the keyboard buffer

Quote:



>>How do you clear the keyboard buffer in QB 4.5 ??

>    You can do this :

>    do
>    loop until INKEY$ = ""

>Eric

        Or you can do this :

        def seg = 0
        poke 1050, peek (1052)

Eric



Fri, 04 Apr 1997 23:42:05 GMT  
 clearing the keyboard buffer

Quote:

>    DO: LOOP WHILE LEN(INKEY$)

This reminded me of a paradox which I've been meaning to raise with this
group in the hope of getting a logical explanation of apparently illogical
logic, if you see what I mean ;-)

Try running the following little test program.  In GWBASIC, QBasic, QB4.5
and PDS 7.1 you find that numbers can be both true and false - or maybe
I'm bonkers #-)

If you enter *exactly* zero then "X is false!".  If you enter a number
that *rounds off* to minus 1 then "X is true!".  Any other number is
both "true" and "false".

What really intrigued me was the behaviour of numbers like:

        -1.4999...

These round off to -1 and are therefore "true" *until* you get enough 9s,
in which case you reach the stage where "-1.5 is true!" then, with another
9 added, you get "-1.5 is true!" *and* "-1.5 is false!" - somewhat odd
don't you think?

No doubt there are perfectly good explanations for this based on binary
arithmetic, but the result did have me wondering what on earth was going
on for awhile :)

The program and a copy of a test run are appended below.  (Note that TRUE.BAS
will APPEND to an output file named LOGICDAT.ANS to store test results.)

Cheers,  Ian S.

10 '********************* TRUE.BAS ************************
20 'Program by Ian Staples 21 Aug 94 to demonstrate the IF
30 'and IF NOT logical operators in BASIC.  Line numbers
40 'ensure the program will work in GW-Basic as well as QBasic,
50 'QuickBasic, etc.  :-)
60 '
70 OPEN "A",1,"LOGICDAT.ANS"
80 A$="":INPUT "Enter a number";A$
90 IF A$<>"" THEN LET X=VAL(A$) ELSE CLOSE:SYSTEM
100 IF X THEN PRINT X;" is true!"
110 IF NOT X THEN PRINT X;" is false!"
120 PRINT #1,"Number tested = ";A$
130 IF X THEN PRINT #1,SPACE$(15);X;" is True!
140 IF NOT X THEN PRINT #1,SPACE$(15);X;" is False!
150 PRINT #1,
160 GOTO 80
170 END

The following output is from TRUE.BAS run under QBasic distributed with
MSDOS 6.0.  The results with GWBASIC and PDS 7.1 are similar, at least
with respect to the behaviour of -1.4999...

*** LOGICDAT.ANS [run under MSDOS 6.0 QBasic, 25 Oct 94] ***

Number tested = 1
                1  is True!
                1  is False!

Number tested = 0
                0  is False!

Number tested = 0.0000000000001
                1E-13  is True!
                1E-13  is False!

Number tested = -0.0000000000001
               -1E-13  is True!
               -1E-13  is False!

Number tested = -1
               -1  is True!

Number tested = -1.5
               -1.5  is True!
               -1.5  is False!

Number tested = -1.49999999
               -1.5  is True!
               -1.5  is False!

Number tested = -1.4999999
               -1.5  is True!

Number tested = -1.499999
               -1.499999  is True!

Number tested = -0.5
               -.5  is True!
               -.5  is False!

Number tested = -0.4999999999
               -.5  is True!
               -.5  is False!

Number tested = -0.50000001
               -.5  is True!
               -.5  is False!

Number tested = -0.5000001
               -.5000001  is True!

*************** End of message & appendix ************

--


c/- P.O. Box 1054 MAREEBA          Phone  : +61 (0)70 921 555 Home 924 847
Queensland Australia 4880            Fax  : +61 (0)70 923 593   "   "   "



Sat, 12 Apr 1997 16:08:16 GMT  
 clearing the keyboard buffer

Quote:
>Try running the following little test program.  In GWBASIC, QBasic, QB4.5
>and PDS 7.1 you find that numbers can be both true and false - or maybe
>I'm bonkers #-)

[much stuff deleted]

BASIC does not provide a BOOLEAN type, or a logical NOT. it does provide
a 1's complement not.
therefore, one cannot say NOT TRUE = FALSE.
  C gets around this by using two different NOTs, "!", which is a logical,
and "~", which is 1's complement.

the only time NOT can be used as a logical not, is during a fully logical
expression, such as
  if not (a = b) then...

--kyle



Sun, 13 Apr 1997 00:32:16 GMT  
 clearing the keyboard buffer

: >  DO: LOOP WHILE LEN(INKEY$)

: This reminded me of a paradox which I've been meaning to raise with this
: group in the hope of getting a logical explanation of apparently illogical
: logic, if you see what I mean ;-)

[code and stuff snipped...]

: Cheers,  Ian S.

Hello Ian,

You have made some interesting observations. I cannot wait to try the code
and see what happens. I have always referred to false as equal to 0 and
true as equal to not false. In other words, false = 0 and true = non-zero.
As LEN(INKEY$) is non-zero it will be true. When INKEY$ is null, its' LEN
is zero and false.

I have worked on computers in the past where 0 = false and 1 = true - I
think this was the old Atari and Apple II PCs. I had never encountered a
-1 = true until the IBM and compatible PCs came along.

I am not sure but the problem my rest with the PC floating point
representation of the numbers in question. I will toy with the code as
see how it does.

Cheers,

Bob

 --
 +-----------------------------------------------------------------------+

 +-----------------------------------------------------------------------+



Sun, 13 Apr 1997 01:21:44 GMT  
 clearing the keyboard buffer
Well, I think the problem has to do with the fact the floating point
is 7 decimal places and all his examples use 8+.  Stuff like that
screws basic up...course, i don't know for sure, but that's what it
looks like to me

Eric
------------------------------------------------------------------------------
    Eric James Kidder         "They say in Hamburg, in the spring time,
         also at               the boys party so much, you can skate home

------------------------------------------------------------------------------



Sun, 13 Apr 1997 03:46:43 GMT  
 
 [ 17 post ]  Go to page: [1] [2]

 Relevant Pages 

1. HOW do I clear the Keyboard Buffer???

2. Clearing the keyboard buffer

3. How do you clear the keyboard buffer?

4. Does Internet Explorer Clear the Keyboard Buffer?

5. how do I clear the keyboard buffer from the VB 5.0

6. How do I clear the keyboard buffer in vb 5.0

7. Mouse/keyboard buffer clear ...possible ?

8. Clear the keyboard type-ahead buffer in VB

9. Clear keyboard buffer?

10. How do I clear keyboard buffer in VB 5.0

11. How to clear keyboard buffer?

12. How to clear keyboard buffer ?

 

 
Powered by phpBB® Forum Software