Page 1 of 1
DO...UNTIL hogging issue
Posted: Wed Aug 24, 2005 5:06 am
by kalc
Code: Select all
'Clicking on box example
DIM x AS INTEGER, y AS INTEGER, button AS Integer
Screen 7
WindowTitle "Mouse clicking example"
Color 2,15
cls
For px = 50 To 70
For py = 50 To 70
PSet (px,py), 14
Next
Next
Do
GetMouse x, y,, button
If button = 1 Then
If x>50 And x<70 Then
If y>50 And y<70 Then i = 1
End If
End If
Loop Until i = 1
Print "Press any key..."
Sleep
This is what happens with all DO...LOOP UNTIL elements, it is constantly checking for a certain occourence and uses all the CPU. How do you get around this?
Posted: Wed Aug 24, 2005 6:27 am
by Z!re
Sleep
use Sleep 1 to Sleep 20
Whatever suits you..
I usually use sleep 1
Posted: Wed Aug 24, 2005 6:43 am
by kalc
But I want it wait for the user to click on the box.
Posted: Wed Aug 24, 2005 8:10 am
by Z!re
Code: Select all
'Clicking on box example
DIM x AS INTEGER, y AS INTEGER, button AS Integer
Screen 7
WindowTitle "Mouse clicking example"
Color 2,15
cls
For px = 50 To 70
For py = 50 To 70
PSet (px,py), 14
Next
Next
Do
GetMouse x, y,, button
If button = 1 Then
If x>50 And x<70 Then
If y>50 And y<70 Then i = 1
End If
End If
Sleep 1
Loop Until i = 1
Print "Press any key..."
Sleep
Try it.. Sleep in FB uses millisecond accuracy, not seconds as in QB..
Sleep 1 means: wait for 1/1000th of a second..
Posted: Thu Aug 25, 2005 12:52 am
by kalc
???! That is not what I'm asking. I know that SLEEP counts in milliseconds in FB, but I want to wait for the user to click on the box. Girls... wadda thay know?
Posted: Thu Aug 25, 2005 12:56 am
by guest
kalc wrote:???! That is not what I'm asking. I know that SLEEP counts in milliseconds in FB, but I want to wait for the user to click on the box. Girls... wadda thay know?
i'd be careful she's libel to take that sword there and
lop your head off...
Posted: Thu Aug 25, 2005 12:57 am
by woot
kalc wrote:???! That is not what I'm asking. I know that SLEEP counts in milliseconds in FB, but I want to wait for the user to click on the box. Girls... wadda thay know?
this is a great way to end up not getting any help at all
Posted: Thu Aug 25, 2005 4:51 am
by kalc
'd be careful she's libel to take that sword there
OK, sorry Z!re, just couldn't help stating the obvious. No, seriously, sorry. But there is real iron in there: libel! God damn, so good... I might publish it! < That is kind of irony!
Posted: Thu Aug 25, 2005 5:18 am
by Z!re
*glares*
kalc wrote:This is what happens with all DO...LOOP UNTIL elements, it is constantly checking for a certain occourence and uses all the CPU. How do you get around this?
To solve the hogging issue, add the sleep 1
kalc wrote:That is not what I'm asking.
kalc wrote:I want to wait for the user to click on the box
Ok, so hogging isnt a problem then? Fine, your code works just fine, stfu.
Next time, before you even think about bashing me, try what I've said.
Posted: Thu Aug 25, 2005 5:25 am
by Seb McClouth
My advice: listen to Z!re, she knows what she's talking about. Now I think about it... we should call here lady Z!re... hehehe
grtz
Seb
Posted: Fri Aug 26, 2005 12:50 am
by kalc
OK Z!re, I am very sorry. I thoought you ws just telling me about the diferrences between FB and QB with Sleep. This has solved my problem, and a problem that occurs in so many of my programs. Thank you Z!re
Posted: Fri Aug 26, 2005 3:53 am
by Z!re
No problem.. good luck with your coding..