Exact timing

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Exact timing

Post by BvG » Thu Jul 12, 2012 2:43 pm

Another way to do it is to send much more messages, and use the milliseconds to time execution of the code. You will run into problems if your code takes longer to run then the alotted 700 milliseconds tho. As with all methods, this only gives somewhat of a precision, but no true precision can ever be achieved.

on mouseUp
send "doStuff" && the milliseconds to me in 70 milliseconds --fires 10 times too much
end mouseUp

on doStuff prevTime
if the milliseconds - prevTime >= 700 then
put the milliseconds into nextTime

--do stuff here

else
put prevTime into nextTime
end if
send "doStuff" && nextTime to me in 70 milliseconds
end doStuff
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Cool Dave
Posts: 35
Joined: Mon Jun 25, 2012 8:44 pm

Re: Exact timing

Post by Cool Dave » Sun Jul 15, 2012 1:55 am

Okay,

It looks like there are several good (though lengthy) ways of doing it.

BTW, I just got 5.5, so now I can open your stacks. I also got Android, so I'll be in the Android Dev section mostly now.

You can see by the code and samples here that everyone does things a little differently. Funny how it's so much easier to read your own code, isn't it?

Thanks everyone for your answers and test stacks...Gotta love Livecode.
Dave

Post Reply