Code: Select all
proc do:format {amount} {
set amount [stripcodes abcgru $amount]
if {[string match "*KB." $amount]} {
set amount [string map {"KB." ""} $amount]
set amount [expr double($amount)*1024]
} elseif {[string match "*MB." $amount]} {
set amount [string map {"MB." ""} $amount]
set amount [expr double($amount)*1024*1024]
} elseif {[string match "*GB." $amount]} {
set amount [string map {"GB." ""} $amount]
set amount [expr double($amount)*1024*1024*1024]
} elseif {[string match "*TB." $amount]} {
set amount [string map {"TB." ""} $amount]
set amount [expr double($amount)*1024*1024*1024*1024]
} elseif {[string match "*PB." $amount]} {
set amount [string map {"PB." ""} $amount]
set amount [expr double($amount)*1024*1024*1024*1024*1024]
} else {
set amount [string map {"B." ""} $amount]
set amount $amount
}
return $amount
}
proc format_1024_units {value} {
set len [string length $value]
if {$value < 1024} {
return [format "%s B" $value]
} else {
set unit [expr {($len - 1) / 3}]
return [format "%.1f %s" [expr {$value / pow(1024,$unit)}] [lindex [list B KB MB GB TB PB EB ZB YB] $unit]]
}
}
Code: Select all
Tcl error [do:addnukes]: syntax error in expression "double(235929600)+double(3.7G)": missing close parenthesis at end of function call
Code: Select all
set newcredits_day [expr double([lindex $userdata_day 0])+double([do:format $amount])]
set newcredits_week [expr double([lindex $userdata_week 0])+double([do:format $amount])]
set newcredits_month [expr double([lindex $userdata_month 0])+double([do:format $amount])]
In my opinion parenthesis is a missing "}" , but i cant find an unclosed one.
i would be very happy for every help in that problem.
greets arti