To update clock, I use this:
Code: Select all
send countUp to me in 0.001 seconds
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Code: Select all
send countUp to me in 0.001 seconds
Code: Select all
on countUp millisecondsCounter
add 0.001 to millisecondsCounter
Code: Select all
doYourCountingStuff
get the milliseconds
put it whereEver
Code: Select all
on DoCountUp
set the numberformat to 00
add 1 to field ClockMilisec
if the field ClockMilisec is "1000" then
put "0" into field ClockMilisec
add 1 to field "clockSec"
if field ClockSec = 60 then
add 1 to field ClockMin
put 00 into field ClockSec
else
end if
end if
send "DoCountUp NewTime" to me in 0.001 second
end DoCountUp
Code: Select all
on mouseUp
updateCounter
end mouseUp
on upDateCounter currentValue
if the optionKey is down then exit to top
put the milliseconds into fld 1
put the long time into fld 2
send "upDateCounter" to me in 0 millisec
end upDateCounter
Code: Select all
on mouseUp
updateCounter
end mouseUp
on upDateCounter currentValue
if the milliseconds is the field "systemMiliseconds" then
add 1 to field clockMilisec
if the field clockMilisec is "1000" then
beep
add 1 to the field clockSec
put "0" into field "clockMilisec"
end if
end if
put the milliseconds into fld systemMiliseconds
send "upDateCounter" to me in 0 millisec
end upDateCounter
Code: Select all
local temp
on mouseUp
put "" into temp
put "" into fld 1
updateCounter
end mouseUp
on upDateCounter
lock screen
put the milliseconds & return after temp
if the optionKey is down then
put temp into fld 1
exit to top
end if
send "upDateCounter" to me in 0 millisec
end upDateCounter
Without going into your latest handler, which still adds a value to a counter that is inherently decoupled from the actual time, what do you think of my earlier middle post, the one with the two fields and a button?But the delay is even bigger than the code in first post in this topic...
Code: Select all
on upDateCounter
lock screen
put the milliseconds & return after temp
if the optionKey is down then
put temp into fld 1
exit to top
end if
send "upDateCounter" to me in 0 millisec
end upDateCounter
Its actually ALT key on WindowsKlaus wrote:Hi croivo,
take a look at the actual handler and guess why nothing is shown in field 1, unless you hit the SHIFT key
If you dont see it, step through the lines mentally and you will seeCode: Select all
on upDateCounter lock screen put the milliseconds & return after temp if the optionKey is down then put temp into fld 1 exit to top end if send "upDateCounter" to me in 0 millisec end upDateCounter
![]()
Best
Klaus
Thanks.dunbarx wrote:What Klaus said, except it is the "option" key.
But that is not important. I only wrote that extra gadget to help you see how, even when the code runs at full speed, faster than milliseconds actually pass, there is no coupling between real time and computed time. Change the wait period to 1 mS. Now you miss certain slots. You just cannot sync...
So you have to figure out what you are really seeking. If a representation of the actual time, use my code. If a running process that can be used perhaps in other ways, then some variant of your current work might well do.
Craig
dunbarx wrote:What Klaus said, except it is the "option" key.
getting old, Craig?dunbarx wrote:...
if the optionKey is down then
...
Yes. But it is still the "Option" key. Let me try one of yours...take a look at the actual handler and guess why nothing is shown in field 1, unless you hit the SHIFT key
getting old, Craig?