#187199 - 2008-04-23 03:01 PM
Unexpected error, ')' required!?!
|
acmp
Getting the hang of it
Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
|
I has an issue
I'm working on some fairly simple code but for some reason I'm getting an EOORO: Expected ')'! nessage. And Yes, I've checked my brackets
My code is: $bgcol = htmlcolour(90, 95, 5)
Function htmlcolour($low, $high, $val) Select Case $val < $low $htmlcolour = "lightgreen" Case $low < $val And $val < $high $htmlcolour = "orange" Case 1 $htmlcolour = "red" EndSelect EndFunction
If I change the (90,95,5) to (90) then it passes along the script with out error (even though the function needs the other params)
Any help would be appreciated. This is holding me up a bit.
TIA
acmp
_________________________
Every day is a school day
|
|
Top
|
|
|
|
#187203 - 2008-04-23 03:24 PM
Re: Unexpected error, ')' required!?!
[Re: Allen]
|
acmp
Getting the hang of it
Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
|
the rest of the code is...
$iniProc = "\serverprocess.ini" $inidisk = "\serverdisk.ini" $Webpage = "\\servermonitor.html"
;region Build HTML
$svrs = Split(Left(ReadProfileString($iniproc, "", ""), ~), Chr(10))
For Each $server in $svrs ;build the html data. Order is ; processes ; disks ; section headers ; server title ? $server $proccolour = "lightgreen" $cpus = Split(Left(ReadProfileString($iniproc, $server, ""), ~), Chr(10)) $disks = Split(Left(ReadProfileString($inidisk, $server, ""), ~), Chr(10)) For Each $cpu in $cpus $line = ReadProfileString($iniproc, $server, $cpu) ;returns the %cpu load $line = CInt($line) $bgcol = htmlcolour(91, 95, $line) ?$bgcol $cpuhtml = $cpuhtml + "<tr bgcolor=$bgcol><td>$cpu</td><td>$line</td></tr>" + @CRLF $proccolour = highcolour($bgcol, $proccolour) Next ;have all CPU's now create table header for Processor $prochtml = "<table>@crlf <tr bgcolour=$proccolour>@crlf <td colspan=2>CPU Load%</td>@crlf </tr>" + $cpuhtml + "</table> Next
I've pulled the data paths from the ini files but everything else is as is.
I'm using ASE and I can't see any missing quotes.
When the htmlcolour bit is commented out I get the same error message at highcolour
_________________________
Every day is a school day
|
|
Top
|
|
|
|
#187204 - 2008-04-23 03:28 PM
Re: Unexpected error, ')' required!?!
[Re: acmp]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
This can't work:
$svrs = Split(Left(ReadProfileString($iniproc, "", ""), ~), Chr(10))
Left(,~) ????
|
|
Top
|
|
|
|
#187205 - 2008-04-23 03:30 PM
Re: Unexpected error, ')' required!?!
[Re: Arend_]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
Also this line:
$prochtml = "<table>@crlf <tr bgcolour=$proccolour>@crlf <td colspan=2>CPU Load%</td>@crlf </tr>" + $cpuhtml + "</table>
Should most likely be:
$prochtml = "<table>"+@crlf+"<tr bgcolour="+$proccolour+">"+@crlf+"<td colspan=2>CPU Load%</td>"+@crlf+"</tr>"+$cpuhtml+"</table>"
|
|
Top
|
|
|
|
#187206 - 2008-04-23 03:32 PM
Re: Unexpected error, ')' required!?!
[Re: Arend_]
|
acmp
Getting the hang of it
Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
|
Left(string,~) is your friend.
It reads all but the last character (work's with right too to get all but the first character).
In this instance it removes the trailing chr(10) from the readprofile string prior to being Splitted. It effectively stops a blank entry being created in the resulting array. it's much easier to code than left(string,(len(string)-1))
_________________________
Every day is a school day
|
|
Top
|
|
|
|
#187207 - 2008-04-23 03:33 PM
Re: Unexpected error, ')' required!?!
[Re: acmp]
|
acmp
Getting the hang of it
Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
|
Yeah, I get the html string is badly formatted, I was just hacking in to see. But when it failed above there I just haven't got round to fixing it.
_________________________
Every day is a school day
|
|
Top
|
|
|
|
#187210 - 2008-04-23 03:49 PM
Re: Unexpected error, ')' required!?!
[Re: Allen]
|
acmp
Getting the hang of it
Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
|
AAAAGGGGHHHHHHH!!!!!!!
Found it
I added the debug code, commented out the 2 calls that didn't work and got an odd error further down. Sure enough it was the missing quote (much kudos to Allen for the original insight and apronk for correcting the line of code, guess I should have copied it into my code.) Added it in and it all works nicely
Thanks for the help chaps, any time I can return the favour...
_________________________
Every day is a school day
|
|
Top
|
|
|
|
#187213 - 2008-04-23 04:14 PM
Re: Unexpected error, ')' required!?!
[Re: acmp]
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4562
Loc: USA
|
as some one else around here has said to me... EUREKA! 
BTW Left($string,~) is golf code for Left($string,-1)
If anyone ever came behind you to fix your code, they most likely would never know what the ~ means, as it's not documented. Saving that one stroke would never be worth the time it would take to figure it out, or explain it.
|
|
Top
|
|
|
|
#187293 - 2008-04-25 10:17 AM
Re: Unexpected error, ')' required!?!
[Re: Glenn Barnas]
|
acmp
Getting the hang of it
Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
|
Will do Glenn,
.
p.s. no sign of the rocket in Nottinghamshire, England.
_________________________
Every day is a school day
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|