On Fri, 12 Nov 99, Leston Drake wrote:
 
> Hi all,
> 
> I've got a "countdown" clock in my app that shows time remaining. For example,
> I want to have it start at "5:00" (five minutes) and count down to "0:00". The
> formatting is important so that it reads correctly. I am using the send command
> to update it every second and to let me know when it's finished. To do this, I
> am using the seconds() function.
> 
> My question is this: Once I compute the seconds remaining, how do I convert it
> to a "MM:SS" format?

Hi Leston,

Essentially, you want to use the trunc() function to determine the
minutes, and the mod operator to get the remainder seconds.  The only
caveat is to add another zero digit if the remainder is a single figure,
e.g. to give 0:00 instead of 0:0.

--where tSeconds is the number of seconds remaining
put tSeconds mod 60 into tRemainder
if the num of chars in tRemainder is 1 then put 0 before tRemainder
put trunc(tSeconds/60) & ":" & tRemainder
  Cheers,
    Michael
-- 
Michael Fisher <[EMAIL PROTECTED]> <http://www.xworlds.com/>
Cross Worlds Computing, MetaCard Distributors, Custom Development.
Tel: +44 (0)131 672 2909.  Fax: +44 (0)1639 830 707.

Reply via email to