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.

Newcomers DBPro Corner / Why does this happen?

Author
Message
Guillermo
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 25th Feb 2003 17:03
Now that I can get beyond printing a simple statement, Ihave realized that all i need to do is give the computer a loop to keep the program running until a condition is met. So, I decided to write a simple program with conditions controlled by mouseckick().
This is it:

x=0
repeat
if mouseclick()=2 then x=x+1
if x=1 then print "11111111111111111111111111111111111"
if x=2 then print "22222222222222222222222222222222222"
if x=3 then print "33333333333333333333333333333333333"
until escapekey()=1
I expected that by rightclicking once, I would get
"111111111111111111111111111111111111"
by rightclicking twice, I would get
"222222222222222222222222222222222222"
and by rightclicking 3 times I would get
"333333333333333333333333333333333333"
Thus, I would end up with
"11111111111111111111111111111111111"
"22222222222222222222222222222222222"
"33333333333333333333333333333333333"
but each line would show up with each click.

What I get is
"11111111111111111111111111111111111"
"22222222222222222222222222222222222"
"33333333333333333333333333333333333"
when I rightclick the first time.

Why???

Guillermo
[b][/b]
Zach
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: Ms, USA
Posted: 25th Feb 2003 17:11
try adding :sleep 100 on the same line as if mouseclick()=2 then x=x+1

so it should look like this...if mouseclick()=2 then x=x+1:sleep 100


Tupelo, Ms
Richard Davey
Retired Moderator
22
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 25th Feb 2003 17:13
Your loop is running so fast that it's registering all the event 3 times in the space it takes for you to click and let go of the mouse button again (if not more!).

Here is one way of stopping this from happening:



Another would be to use a timer() event to check to see how long has passed since you last clicked and then detect if you've clicked again.

Cheers,

Rich

"Gentlemen, we are about to short-circuit the Universe!"
DB Team / Atari ST / DarkForge / Retro Gaming
Guillermo
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 25th Feb 2003 21:33
OK, I fixed it. I tried both ways and it worked fine
Thanks!

Login to post a reply

Server time is: 2024-11-24 04:58:18
Your offset time is: 2024-11-24 04:58:18