> To be more specific:
> •  I'm not sure how I'd assign the result of *info to a button -- 
> although I could probably figure this out... I think.


You use *info by making the label of a button start with *info.  
Search help for details of all usages.  The specific usage
*info expr(...)
causes an expression represented here by ... to be evaluated each 
second and displayed on the button.

To get the number of days:hours:minutes:seconds to a given date, the 
easist approach is to create a script file countdown.txt containing:

function countdown(targetdate)
local totalsec = date.subseconds(targetdate, date.now)

local days = totalsec / (24*3600)
local hours = fill("00", totalsec %(24*3600)  /  3600)

local minutes = fill ("00", totalsec%3600 / 60)
local seconds = fill ("00",totalsec % 60)

quit (days ++ ":" ++ hours ++ ":" ++ minutes ++ ":" ++ seconds)


Test this a few times with a command line like
win.debug("20090628130101")
which gives time until 2009 Jun 28 at 1:01:01 PM.

When you are happy it is working, put
*info expr(.countdown("20090628130101"))
as a button label.

The sample I referenced avoided the script call by encoding it all 
into a single expression.  That example was for a much simpler 
case.  

For the above, the expression would start something like:
*info expr(assign(totalsec, date.subseconds(targetdate, date.now)++ 
totalsec/(24*3600) ++ ":" ++ etc.
where I leave the etc. as an exercise for the reader.  The only 
advantage of avoiding the script call is less CPU usage.






Reply via email to