|
Chartdirector scprit vb erreur |
Posted by PITP2 on Oct-16-2010 22:33 |
|
hi,
anybody can help me because i have this error message (Script compile error: Method arguments must be enclosed in parentheses.on line 24) when i use this script.
Imports ChartDirector
sub main()
dim objConn, strConnectionString, rsDay, sql, rdVeille, sqlveille
dim data(24)
dim labels (24)
dim i, j
i = 0
j = 0
objConn = CreateObject("ADODB.Connection")
strConnectionString = "DRIVER=Microsoft.Jet.OLEDB.4.0;Database=C:\\Program Files\\HomeSeer HS2\\data\\1wire\\1wire.mdb;"
objConn.Open strConnectionString
rsDay = createObject("ADODB.recordset")
sql = "select rfxtime, round(rfxvalue,0) from Temperature where rfxsensor = Piscine and rfxdate || '-' || substr('0000000000' || month, -2, 2) || '-' || substr('0000000000' || day, -2, 2) = date('now','localtime') group by year, month, day, hour;"
rsDay.open sql, objConn
rfxvalue = rsDay("rfxvalue")
heure = rsDay("rfxtime")
do until rsDay.EOF
data(i) = rfxvalue
i = i+1
rsDay.moveNext
loop
cd = CreateObject("ChartDirector.API")
c = cd.XYChart(500, 300)
c.setPlotArea(45, 45, 420, 200)
c.addAreaLayer(data, &H8000ff00, "Aujourd'hui", 5)
c.xAxis().setLabels(labels)
c.xAxis().setLabelStep(2)
c.addLegend(55, 260, False, "", 8).setBackground(cd.Transparent)
c.addTitle("Temp?rature du jour", "timesbi.ttf", 14).setMargin2(0, 0, 8, 8)
c.yAxis().setTitle("Degr?s")
c.xAxis().setTitle("Heure")
c.makeChart("graph\\temp.png")
rsDay.close
rsVeille.close
end sub |
Re: Chartdirector scprit vb erreur |
Posted by Peter Kwan on Oct-17-2010 17:52 |
|
Hi PITP2,
The error message just means your code has a syntax error in line 24. Because you have not included the original file, so we cannot know which line is "line 24".
Anyway, to diagnose the problem, please find out the line that contains the error, and make sure it is valid according to your programming language.
By reading your code, it seems to be written in VB.NET, or VB 2003, 2005, 2008 or 2010. But your code is not correct according to these language syntax. For example, in the line "objConn.Open strConnectionString" should be "objConn.Open(strConnectionString)" according to the language syntax of these VB.
Hope this can help.
Regards
Peter Kwan |
Re: Chartdirector scprit vb erreur |
Posted by PITP2 on Oct-21-2010 01:59 |
|
thank tou for your answer
line 24 is this instruction
c.setPlotArea(45, 45, 420, 200)
this script is written in vb but i don't know how i can find my vb version ..... (i use homeseer and my os his XP sp3) |
Re: Chartdirector scprit vb erreur |
Posted by Peter Kwan on Oct-21-2010 02:38 |
|
Hi PITP2,
It is important that you know which programming language you are using. The "VB" is a class of programming languages. It contains of classical VB (VB6), VBScript, VBA, as well as the VB in the .NET platform (usually called VB.NET, 2002, 2003, 2005, 2008, 2010). The syntax types of VB are not exactly compatible.
In VB6, VBScript and VBA, the line "c.setPlotArea(45, 45, 420, 200)" has a syntax error. It should be "Call c.setPlotArea(45, 45, 420, 200)".
Many of the lines have other kinds of error too. For example, "objConn = CreateObject("ADODB.Connection")" should be "Set objConn = CreateObject("ADODB.Connection")". (In VB6/VBScript/VBA, object reference assignment should use "Set", while scalar or array assignment should not use "Set".) The latter kind of error is a runtime error, which means the error will not occur during script compilation, but will occur after the system have successful compile the script and attempt to run it.
So I think the most important thing now is to find out which programming language you are using, and then read the documentation of that programming language. It is hard to write a correct program if you do not know the syntax of the programming language.
Regards
Peter Kwan |
Re: Chartdirector scprit vb erreur |
Posted by PITP2 on Oct-21-2010 04:13 |
|
I think that it's VBScript ... |
Re: Chartdirector scprit vb erreur |
Posted by Peter Kwan on Oct-21-2010 21:20 |
|
Hi PITP2,
If the code is in VBScript, then there are a lot of errors in the code. (I found 8 syntax mistakes just by briefly reading the code. In addition, there are some logical errors.)
To solve the problem, please make sure you know how to write VBScript. You may need to read the VBScript documentation. There are also some VBScript examples in ChartDirector for ASP/COM/VB. (Your current code is very different from the VBScript examples in ChartDirector for ASP/COM/VB.)
Hope this can help.
Regards
Peter Kwan |
Re: Chartdirector scprit vb erreur |
Posted by PITP2 on Oct-22-2010 03:07 |
|
thank you for your help
i have re-wrote the code and now i have only one error with my database connection.
error message ==> Running script, script run or compile error in file: graph piscine.vbs-2147467259:[Microsoft][Gestionnaire de pilotes ODBC] [Microsoft] [ODBC Driver Manager] Data source name not found and no default driver specified in line 10
the line 10 is this line ==> objConn.Open(strConnectionString)
Have you an idea of the problem ?
sub main()
dim objConn, strConnectionString, rsDay, sql, rdVeille, sqlveille
dim data(24)
dim labels (24)
dim i, j
i = 0
j = 0
set objConn = CreateObject("ADODB.Connection")
strConnectionString = "DRIVER=Microsoft.Jet.OLEDB.4.0;Database=C:\\Program Files\\HomeSeer HS2\\data\\1wire\\1wire.mdb"
objConn.Open(strConnectionString)
rsDay = createObject("ADODB.recordset")
sql = "select rfxtime, round(rfxvalue,0) from Temperature where rfxsensor = Piscine and rfxdate || '-' || substr('0000000000' || month, -2, 2) || '-' || substr('0000000000' || day, -2, 2) = date('now','localtime') group by year, month, day, hour;"
rsDay.open sql, objConn
rfxvalue = rsDay("rfxvalue")
heure = rsDay("rfxtime")
do until rsDay.EOF
data(i) = rfxvalue
i = i+1
rsDay.moveNext
loop
cd = CreateObject("ChartDirector.API")
c = cd.XYChart(500, 300)
call c.setPlotArea(45, 45, 420, 200)
call c.addAreaLayer(data, &H8000ff00, "Aujourd'hui", 5)
call c.xAxis().setLabels(labels)
call c.xAxis().setLabelStep(2)
call c.addLegend(55, 260, False, "", 8).setBackground(cd.Transparent)
call c.addTitle("Consommation Electrique du Jour", "timesbi.ttf", 14).setMargin2(0, 0, 8, 8)
call c.yAxis().setTitle("Kw")
call c.xAxis().setTitle("Heure")
call c.makeChart("graph\\conso_electrique.png")
rsDay.close
rsVeille.close
end sub |
Re: Chartdirector scprit vb erreur |
Posted by Peter Kwan on Oct-22-2010 05:30 |
|
Hi PITP2,
The error message just means your connect string is incorrect. Either you have not installed the database driver mentioned in the connect string (Microsoft.Jet.OLEDB.4.0), or the other parts of the connect string is incorrect.
You may refer to Microsoft documentation on how to use the Microsoft database driver and how to connect to a Microsoft Access database.
http://msdn.microsoft.com/en-us/library/ms681754(VS.85).aspx
Hope this can help.
Regards
Peter Kwan |
|