This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Make a sort of countdown proc

Old posts that have not been replied to for several years.
Locked
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Make a sort of countdown proc

Post by metroid »

got it to work with help from someone else

Code: Select all

proc countdown {seconds} {
set minutes [expr $seconds / 60]
set seconds [expr $seconds % 60]
set hours [expr $minutes / 60]
set minutes [expr $minutes % 60]
set days  [expr $hours / 24]
set hours [expr $hours % 24]
return "[format "%d days, %02d:%02d:%02d" $days $hours $minutes $seconds]"
}
Only thing left to fix is that it won't choke on non-integers
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

Code: Select all

if ![regexp \[0-9\] $seconds] {#not integer
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

or try [string is integer -strict $seconds], this would be even true for integers surrounded by whitespaces (which is still a valid integer for expr) and is false on an empty string.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Yeah, i was attempting to make a proc which will display the exact count down in seconds etc,

As you are on Quakenet, you are probably familair with Q9 which uses the exact same countdown thing in his permban function :)
Locked