egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

expr double issue

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
tonyrayo
Voice


Joined: 31 Jul 2003
Posts: 20
Location: Waldorf, MD

PostPosted: Wed Apr 04, 2007 4:08 am    Post subject: expr double issue Reply with quote

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
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Apr 04, 2007 7:50 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber