Since we don't have a Hints and Tips section, I'll post this here.
Sometimes, your program may have a loop that checks for a particular key being pressed, and then does something.
But what happens if the user presses the key several times, or holds it down long enough for auto-repeat to start? ::)
Next time through your loop you find - yes, the key has been pressed - and off goes your program again - wrongly this time.
What's needed is to clear the keyboard buffer of any extraneous values before you test for the keypress.
If it is a console program, you would use:
' clear keyboard buffer
do: until inkey$ = ""
But that's no use in a program using windows. In this case, you need:
' clear keyboard buffer
do: until getkeystate(0x20) = 0
In this example, I'm testing for the spacebar (0x20), but you can use any key code for this purpose.
all the best, :)
Graham
Excellent tip, Graham!
Larry
Quote from: LarryMc on November 05, 2007, 10:47:50 AM
Excellent tip, Graham!
This tip saved my bacon today, almost ten years later!
Egil
Glad you found it Egil .. :)
Nice to see CBasic is still in action.
I'm just playing down my shed with a 90 year old radio .. ::) An Osram Music Magnet dated 1928.
You can see the amazing solid brass tuning and regeneration capacitors in this link .. beautiful - you don't find stuff like that these days.
http://www.radiomuseum.co.uk/osram.html (http://www.radiomuseum.co.uk/osram.html)
All the best, :)
Graham
That radio is a real beauty Graham!
I don't think work like that can be done by the robots they are using in the electronics industry today.
I have used most of the afternoon making a passive three channel audio mixer. One of my friends is a keen SWL, specialising in catching Carribean and South American MW broadcasters. He has two half mile long Beverage antennas, and what he can receive with his old ICOM R-70 and the newer ICOM R-75 is almost unbeleivable.
He has just purchased a digital recorder from Sangean (http://www.universal-radio.com/catalog/misc/4101.html (http://www.universal-radio.com/catalog/misc/4101.html)), and he is going to use the audio mixer between the receivers and his new recorder.
It was impossible to get good oldfashioned logaritmic potmeters for chassis mounting here in Norway. Had to get them from Germany. The postman dropped then in my mailbox today.
And for using CreativeBasic... I use it all the time for experimenting. And the problems this morning (it was actually my young friends that called from school shouting for help), was solved after a quick search on the forum. Their program sometimes crashed, after using the Enter Key for inputting data.
I also promissed to translate norwegian texts to english, and to help them make a User Manual for their creation on friday afternoon, and after that their code will be posted here on the forum. Almost can't wait to see what they have done.
Egil