At 09:33 PM 11/7/00, Steven Sacks wrote:
>Hello. I need some math help.
>
>I need to compute remaining time based on
>a total frame count compared to the current frame.
>It's a 10fps movie.
>
>Here's the elapsed time script.

Here's one way:
on computeTime totalFrames, rate
   unitsLeft = totalFrames - the frame
   secs = 0
   mins = 0
   secs = unitsLeft / rate
   if secs >= 60 then
     mins = secs / 60
     secs = secs mod 60
   end if
   mins = string(mins)
   secs = string(secs)
   if mins.char.count < 2 then mins = "0" &mins
   if secs.char.count < 2 then secs = "0" &secs
   return mins &":" &secs
end

put computeTime(the lastFrame,10)
-- "00:20"

But this reminds me that some years ago, I wrote a somewhat intricate set 
of handlers to allow a user to convert frames to SMPTE time & back again 
with a simple calculator thrown in. Then somebody happened to mention 
Lingo's framesToHMS and HMStoFrames functions. I went back to that older 
version of Dir & sure enough, those commands were available even then!

So . . .

on computeTimeLeft totalFrames, rate
   framesLeft = totalFrames - the frame
   return framesToHMS(framesLeft,rate,0,1)
end

put computeTimeLeft(the lastFrame,10)
-- " 00:00:20.02 "

It even has a DROP FRAME switch!!!


--
Mark A. Boyd
Keep-On-Learnin' :)


[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to