| View previous topic :: View next topic |
| Author |
Message |
tonyrayo Voice
Joined: 31 Jul 2003 Posts: 20 Location: Waldorf, MD
|
Posted: Wed Apr 04, 2007 4:08 am Post subject: expr double issue |
|
|
Hi guys, I am trying to help a friend debug a script. I have only started learning tcl and haven't gotten to math functions yet. The question would be best stated in the code that's being used.
First is the code that retrieves the info for us...
| Code: | | if {[catch {exec cat /proc/cpuinfo | grep "cpu MHz"} cpuspeed]} {set cpuspeed "Unknown"} |
Then according to that code it should parse the Mhz command or reply with "Unknown".
Then to parse "cpu MHz : 1596.000" (without the quotes)
| Code: | | set cpuspeed "[expr double(round([string map {"cpu MHz : " ""} $cpuspeed]))]" |
What is going wrong? Is the mhz not coming back correctly? This is the error code.
| Code: | | Tcl error [msg_uptime]: syntax error in expression "double(round(1596.000 1596.000))": missing close parenthesis at end of function call | so I assume it has to do with the double command. It worked when used with a 700mhz CPU. The only other code related to cpu further down is this... | Code: | if {$cpuspeed >= 1000} {
set cpuspeed "[expr $cpuspeed/1000]GHz"
} else {
set cpuspeed "[expr round($cpuspeed)]MHz" |
I know this is something easy but I am way too tired and sick to figured it out myself or skip ahead in my tcl books and try to fill in the knowledge. Any help would make me much grateful. Thank you.
- Tony R. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Wed Apr 04, 2007 7:50 am Post subject: |
|
|
Would this be a system with multiple cores or such?
The reason for your error, is that you got two cpu-speeds in that string. Yet, round() only expects one float, and thus starts nagging when it finds something else than a closing ")".
1596.000 is most certainly small enough for tcl to handle, so size should'nt matter _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|