Speed optimisation

Wouter wouter.abraham at scarlet.be
Wed Oct 5 05:04:24 EDT 2005


Hi,

May be this will do?
  (just to give an idea, can be tweaked)

function newTime oldTime,addedSec
   set the twelvehourtime to false
   convert oldTime to seconds
   add addedSec to oldTime
   convert oldTime to long time
   if length(oldTime) = 8 then return oldTime
   else return "0" & oldTime
end newTime


Greetings,
Wouter


On 05 Oct 2005, at 08:58, Rob Beynon wrote:

> Dear Colleagues,
>
> I have a function that takes a time in this format
>
> hh:mm:ss.s
>
> and to which I add a variable number of seconds, then output the
> updated time in the same format. hh can be greater than 24!
>
> Here's the function. Problem is, it seems slow (I need to do this call
> about 150,000 times each file I process). I would appreciate any
> insights into making this function faster
>
> function newTime oldTime,addedSec
>     put the replacetext(oldTime,":"," ") into splitTime
>     put the first word of splitTime into h
>     put the second word of splitTime into m
>     put the third word of splitTime into s
>     put s + addedSec into newSec
>     put newSec mod 60 into remainSec
>     put (newsec-remainSec)/60 into addedMin
>     put m + addedMin into newMin
>     put newMin mod 60 into remainMin
>     put (newMin-remainMin)/60 into addedHr
>     put h + addedHr into newHr
>     if length(remainSec) = 1 then put "0" & remainSec into remainSec
>     if length(remainMin) = 1 then put "0" & remainMin into remainMin
>     if length(newHr) = 1 then put "0" & newHr into newHr
>     put newHr & ":" & remainMin & ":" & remainSec into newTime
>     return newTime
> end newTime
>
> --  
> All best wishes,
> Rob
>
> (Created at 07:55 on 05/10/2005)
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list