Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 3rd Nov 2010 21:38
Whats up with the response of this command. I noticed while doing a delete button check that it ever skips checks or misses them. If you run this test and change the sync rate between 10-30-60 you can see that it misses some checks:



Is the command intended to do this?

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 3rd Nov 2010 23:29
ASC() only returns the ascii value of the first character of a string. If I'm not mistaking, it's very possible that entry$() returns multiple characters at once if you type fast.

Cheers!
Sven B

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Nov 2010 23:31
I can't reproduce your problem, however remember that ASC only gives you the value for the first character in the string when there are multiple characters - could this be the problem?

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 3rd Nov 2010 23:46 Edited at: 3rd Nov 2010 23:49
Quote: "ASC() only returns the ascii value of the first character of a string. If I'm not mistaking, it's very possible that entry$() returns multiple characters at once if you type fast."


The issue really is the characters it doesn't return and why, is it a bug, or is it just how it works.

entry$() is the issue. If a key is pressed, then every loop it should return that key, but it doesn't. Even if the key is held down from loop to loop, depend on sync rate, say 60, there's a delay with the initial key press then it misses entries every other loop. Press/hold any key with this example:



A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 3rd Nov 2010 23:59 Edited at: 3rd Nov 2010 23:59
Hi Sasuke,

If you're talking about the "holes" between some checks then that's also perfectly normal. When keeping a key pressed, an event is posted with a certain time interval. If that interval is bigger than the time between each check, then of course it will sometimes not "detect" a key being pressed.

Sven B

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 4th Nov 2010 00:05 Edited at: 4th Nov 2010 00:05
Hi Sven,

I see. But does that only apply to the entry$() command, because keystate() and scancode() return a key press without fail.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 4th Nov 2010 01:42 Edited at: 4th Nov 2010 01:46
Quote: "But does that only apply to the entry$() command"


Yes, ENTRY$() is designed to remember all keys pressed since the last CLEAR ENTRY BUFFER command. If you want extreme accuracy from ENTRY$() use a FOR/NEXT loop to extract each key stored in ENTRY$().

In the following code snip press as many keys as you want as fast as you want and hit the spacebar to pause. It'll show all keys stored in ENTRY$() no matter how long it is.



Quote: "because keystate() and scancode() return a key press without fail."


KEYSTATE() is limited because it will only show so many keys. If you hold down 10 keys at a time it'll only show 3 or 4 (if that). It's a hardware limit on our keyboards. If you had the newest coolest keyboard with anti-ghosting you could detect up to 26 keys with KEYSTATE().

Microsoft SideWinder X4 Keyboard:
http://www.amazon.com/Microsoft-JQD-00001-SideWinder-X4-Keyboard/dp/B002ZV51DI

SCANCODE() is also limited to what KEYSTATE() number the key is. If you used SCANCODE() and held down S it'll show 31 but if you kept it held down and pressed A it'll only show 30 even though your also pressing S. SCANCODE() only shows the lowest numbered key. That's why it really should only be used to find out the KEYSTATE() number for each key you want to use and as a quick way to make sure no keys are currently being pressed.

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 4th Nov 2010 01:50 Edited at: 4th Nov 2010 01:51
Thanks you Grog and Sven (and IanM don't I forget) for filling in those holes in my brain. Though I've been coding awhile, I never knew how exactly things were returned, hence the thread, so cheers guys

Out of interest, I think information like this should be added to the help files, especially the limitations of things, don't you agree?

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.

Login to post a reply

Server time is: 2026-07-26 05:03:55
Your offset time is: 2026-07-26 05:03:55