Clear keyboard-buffer

New to FreeBASIC? Post your questions here.
Post Reply
Stormy
Posts: 198
Joined: May 28, 2005 17:57
Location: Germany
Contact:

Clear keyboard-buffer

Post by Stormy »

Hi guys,

i need a better way to clear the keyboard-buffer than this one:

Code: Select all

WHILE INKEY$ <> "": WEND
regards,

Stormy
v1ctor
Site Admin
Posts: 3804
Joined: May 27, 2005 8:08
Location: SP / Bra[s]il
Contact:

Post by v1ctor »

You could use "while GETKEY <> 0: wend", not that it will speed up anything really..
VonGodric
Posts: 997
Joined: May 27, 2005 9:06
Location: London
Contact:

Post by VonGodric »

while not len(inkey$)
wend
lillo
Site Admin
Posts: 447
Joined: May 27, 2005 8:00
Location: Rome, Italy
Contact:

Post by lillo »

If too much typing is your problem, you could do:

Code: Select all

#define clear_keybuf    while inkey$<>"": wend

clear_keybuf
Stormy
Posts: 198
Joined: May 28, 2005 17:57
Location: Germany
Contact:

Post by Stormy »

No, the problem is that my program is stucking for awhile. I'am working on an RPG and when every time this this

Code: Select all

while inkey$<>"": wend
will be loaded, the game stucks for a little moment... In DOS-times there was a little interrupt for that necessary...
Stormy
Posts: 198
Joined: May 28, 2005 17:57
Location: Germany
Contact:

Post by Stormy »

It is ok now ! I tried out MULTIKEY and I'm happy with this ! Works so smoothly... =)
Antoni
Posts: 1393
Joined: May 27, 2005 15:40
Location: Barcelona, Spain

Victor: What's GETKEY?

Post by Antoni »

Victor:
Not really a hidden keyword, it's in the keywords list , but you never explained it. And it's in my to do list for the Wiki.....
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Post by DrV »

IIRC, GetKey just returns an integer version of what InKey$ would return... is this correct?
Antoni
Posts: 1393
Joined: May 27, 2005 15:40
Location: Barcelona, Spain

Post by Antoni »

You are doing the DOS version and dont' know it??????
v1ctor
Site Admin
Posts: 3804
Joined: May 27, 2005 8:08
Location: SP / Bra[s]il
Contact:

Post by v1ctor »

Correct.. after 300 or so runtime functions it becomes not so easy to remember.. i can't remember the number of rt functions either.. nm
Antoni
Posts: 1393
Joined: May 27, 2005 15:40
Location: Barcelona, Spain

Post by Antoni »

Just kidding...

Well, i did some testing and I can refresh your memory ;)

EDITED:
It removes a char from the keyboard buffer, waiting for it if the buffer is empty and returns it's ascii value. If it's an extended key (so returning 2 chars), it skips the char 255 at the front and returns the ASCII of the second one.
Post Reply