Re: countdown display code
- Posted by Senator Aug 17, 2020
- 1426 views
I revised Irv's 1st revision using round instead of trunc, display instead of printf and sleep(.1) instead of sleep(1) per his sample code.. works like charm.
Thanks, again,
function DaysBetweenDates(datetime dt1,datetime dt2) atom h,m,s=diff(dt1,dt2), d=s/86400 -- days.xx h=frac(d)*24 -- hours.xxx d=round(d,1) -- days m=frac(h)*60 -- minutes.xxx h=round(h,1) -- hours s=frac(m)*60 -- seconds.xxx m=round(m,1) -- minutes s=round(s,1) -- seconds return {d,h,m,s} end function public procedure now_until(datetime dt2={2021,1,20,0,0,0}) sequence bal, pos = get_position() object prevbal = 0 loop do text_color(BRIGHT_WHITE) position(pos[1],pos[2]) puts(1," ") position(pos[1],pos[2]) text_color(BLUE) bal=DaysBetweenDates(now(),dt2) display("[]-[]:[]:[] ",bal,0) sleep(.1) until equal(bal,dt2) end loop end procedure now_until() -- 155-3:4:27