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.

DarkBASIC Discussion / small and annoying problem that needs looked at

Author
Message
kRx
20
Years of Service
User Offline
Joined: 2nd Apr 2005
Location: Canterbury, Kent, UK
Posted: 3rd Apr 2005 01:26
when you press the down key it misses out highlighting "2" and goes to "3" but from "3" if you press the upkey it highlights "2". can anyone tell me whats going on (or not going on) as i cant see any problems.



Thanks



kR
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 3rd Apr 2005 16:02
Yup u have a problem:
if key(208)=1 and select = 1 then select = 2
(now select is 2)
if key(208)=1 and select = 2 then select = 3
(select was 2 and the key is pressed => select is 3)
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 3rd Apr 2005 21:14 Edited at: 3rd Apr 2005 21:25
kRx,

Try this, after initializing select to 1:



This will fix your problem, with a plus, that there is less code to execute and the nested evaluating if statements are only executed when either of the two keys are pressed. The code above gets rid of the need for the and statements and simply resets select if it goes out of bounds.

We know that only when the variable is being incremented, will it ever go above 3. So, if key(208) is pressed, if select is then incremented above 3, it is then reset to 3. This never allows for it to be incremented above 3. Same goes for pressing the down key. The same rules apply for when the downkey is being pressed, except vise versa. The variable is decremented, and since it's lowest number can only be a 1, then we say that if it goes below the value of 1, we make it to again be 1.

+NanoBrain+
kRx
20
Years of Service
User Offline
Joined: 2nd Apr 2005
Location: Canterbury, Kent, UK
Posted: 4th Apr 2005 00:33
u guys are legends! worked perfectly i see the problem now *slaps self*

kR

Login to post a reply

Server time is: 2025-05-23 08:21:36
Your offset time is: 2025-05-23 08:21:36