Time-Lapse Calculator - Script Writing - CHDK Forum

# Time-Lapse Calculator

• 2 Replies
• 3605 Views

#### NewbieToobie

• 102
##### Time-Lapse Calculator
« on: 05 / September / 2008, 21:32:52 »
I was trying to learn how to write scripts because I wanted to have a simple way to find out how many frames I would need for a video of a certain length. I came up with the script below. Could someone look this over and see if is written right? It SEEMS TO BE working properly, but I'm not sure I did the calculations and used the basic commands right. Especially that % command thing in the print statements. I was really bad in math when it came to rate, distance, time calculations for some stuff. My mind can't wrap itself around time related concepts. I'm sure I must have done something wrong.

Code: [Select]
`@title Time-Lapse Calc@param h Video Hours Needed@default h 0@param m Video Minutes Needed@default m 1@param s Video Seconds Needed@default s 0@param f Frame-Rate@default f 30@param M Shoot Interval Minutes@default M 0@param S Shoot Interval Seconds@default S 10rem Shoot Interval is your intervalometer shooting raterem calculate needed video-length in secondsv=h*3600+m*60+srem calculate intervalometer shoot-time in secondsi=M*60+Srem calculate total shooting time needed in secondst=f*v*irem display results in consoleprint "Shoot " v*f " frames,"print "for " t/3600 " H, " t%3600/60 " M, " t%60 " S"end`

#### rylangrayston

• 4
##### Re: Time-Lapse Calculator
« Reply #1 on: 14 / September / 2008, 13:35:44 »
Your math looks correct to me.

I used to code in Qbasic a long time ago
I would suggest using brackets to make the math more readable,
making it obvious that       v=h*3600+m*60+s        is calculated like this     v=(h*3600)+(m*60)+s

I find it to be a good habit for when you get into large equations.

#### A_Str8

• 59
##### Re: Time-Lapse Calculator
« Reply #2 on: 15 / September / 2008, 09:04:19 »
If I remember right, capital variables will not work in the param statements at the beginning. You can use them in the rest of the script, but in that part, you can only use lowercase.

### Related Topics

SimplePortal 2.3.6 © 2008-2014, SimplePortal