Page 1 of 1 1
Topic Options
#187199 - 2008-04-23 03:01 PM Unexpected error, ')' required!?!
acmp Offline
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:
 Quote:
$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
#187200 - 2008-04-23 03:06 PM Re: Unexpected error, ')' required!?! [Re: acmp]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
This works just fine for me.
Is this all the code or is there something extra?

 Code:
Break on

$bgcol = htmlcolour(90, 95, 5)
?$bgcol
Sleep 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
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#187202 - 2008-04-23 03:19 PM Re: Unexpected error, ')' required!?! [Re: Mart]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Although I don't see it here in this code, it feels like a missing quote elsewhere.
Top
#187203 - 2008-04-23 03:24 PM Re: Unexpected error, ')' required!?! [Re: Allen]
acmp Offline
Getting the hang of it

Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
the rest of the code is...

 Quote:
$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_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
This can't work:
 Code:
$svrs = Split(Left(ReadProfileString($iniproc, "", ""), ~), Chr(10))


Left(,~) ????

Top
#187205 - 2008-04-23 03:30 PM Re: Unexpected error, ')' required!?! [Re: Arend_]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Also this line:
 Code:
$prochtml = "<table>@crlf <tr bgcolour=$proccolour>@crlf <td colspan=2>CPU Load%</td>@crlf </tr>" + $cpuhtml + "</table>


Should most likely be:
 Code:
$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 Offline
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 Offline
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
#187208 - 2008-04-23 03:41 PM Re: Unexpected error, ')' required!?! [Re: acmp]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Maybe it has something to do with the $line variable. Stick this in your code and see what it tells you. Maybe its a Val() issue.

? "Line=" + $line + " " + vartypename($line)
$line = CInt($line)
? "Line=" + $line + " " + vartypename($line)

Top
#187210 - 2008-04-23 03:49 PM Re: Unexpected error, ')' required!?! [Re: Allen]
acmp Offline
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 Administrator Online   shocked
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
#187216 - 2008-04-23 05:23 PM Re: Unexpected error, ')' required!?! [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Absolutely!! Using undocumented shortcuts is NOT your friend.

Also - look for the SANITY udf, which would have found this error quite easily. (or grab the KixDev package from my web & use KGen, which performs a sanity check on your code while resolving UDF dependencies.)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#187293 - 2008-04-25 10:17 AM Re: Unexpected error, ')' required!?! [Re: Glenn Barnas]
acmp Offline
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
#187304 - 2008-04-25 03:24 PM Re: Unexpected error, ')' required!?! [Re: acmp]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Hey! Thanks for keeping an eye out though!

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.066 seconds in which 0.027 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org