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.

[SOLVED] missing close parenthesis

Help for those learning Tcl or writing their own scripts.
Post Reply
a
aRTiST
Voice
Posts: 4
Joined: Fri Apr 17, 2009 11:01 am

[SOLVED] missing close parenthesis

Post by aRTiST »

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]]
	}
}
This is part of a script that im trying to use, but i allways got the following error

Code: Select all

Tcl error [do:addnukes]: syntax error in expression "double(235929600)+double(3.7G)": missing close parenthesis at end of function call
The error leads to that part :

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
Last edited by aRTiST on Sat Apr 18, 2009 1:55 pm, edited 2 times in total.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

A close parenthesis is actually a ")". Most likely, it's this:

Code: Select all

double(3.7G)
where the G is to blame. Edit it to use proper integers, and it should work.

Edit: Think I hit submit abit early. It would seem the do:format proc fails to remove that G. It does use string map to remove GB, but that would fail to remove a simple G. Possible faulty/corrupt data in $amount ?
NML_375
a
aRTiST
Voice
Posts: 4
Joined: Fri Apr 17, 2009 11:01 am

Thanks a lot :D

Post by aRTiST »

First of all THX :D

The hint leads me the right way.

There was an "Sign" in that var That "" wouldnt be stripped by "set amount [stripcodes abcgru $amount]"

Now i have to remove that crap, not sure how but perhaps ill find a way.

thx nml375
Post Reply