chooby
08-21-2006, 11:46 AM
Hi im using the follwoing code to call a sub/function which is in a different file, but get an error message for the inc file. Basically what i want to do is to pass the result_query_id & result_run_id variables to the function, which will calculate the number and pass that number back to the main page and save it into the variable "answer"
result_query_id = Rs2("query_id")
result_run_id_temp = Rs2("next_run")
result_run_id = result_run_id_temp - 1
%>
<!-- #INCLUDE FILE="callSpeed.inc"-->
<%
answer = Speed_Per_Ball(result_query_id, result_run_id)
Response.Write (answer)
Response.Write ("<br />")
But then i get this error
Microsoft VBScript compilation error '800a03ea'
Syntax error
/cosa5web/callSpeed.inc, line 2
sub Speed_Per_Ball (result_query_id, result_run_id)
^
here is the code for the callSpeed.inc file
<%
sub Speed_Per_Ball (result_query_id, result_run_id)
Tot_Speed = 0
Tot_Balls = 0
set Cn3=server.createobject("ADODB.connection")
set Rs3=server.createobject("ADODB.recordset")
Cn3.open dsn
sql3 = "select * from Hawk_Eye where (query_id = '" & result_query_id & "') and (run_id = '" & result_run_id & "')"
Rs3.open sql3, Cn3
if Rs3.eof <> true then
while not Rs3.eof
Tot_Speed_temp = Rs3("Speed_at_Release")
Tot_Speed = Tot_Speed + Tot_Speed_temp
Tot_Balls = Tot_Balls + 1
Rs3.movenext
wend
end if
set Rs3=nothing
Cn3.close
Speed_Per_Ball = Tot_Speed / Tot_Balls
End sub
%>
I was following the code from Link (http://www.webdeveloper.com/forum/showthread.php?t=22710)
Any ideas???
result_query_id = Rs2("query_id")
result_run_id_temp = Rs2("next_run")
result_run_id = result_run_id_temp - 1
%>
<!-- #INCLUDE FILE="callSpeed.inc"-->
<%
answer = Speed_Per_Ball(result_query_id, result_run_id)
Response.Write (answer)
Response.Write ("<br />")
But then i get this error
Microsoft VBScript compilation error '800a03ea'
Syntax error
/cosa5web/callSpeed.inc, line 2
sub Speed_Per_Ball (result_query_id, result_run_id)
^
here is the code for the callSpeed.inc file
<%
sub Speed_Per_Ball (result_query_id, result_run_id)
Tot_Speed = 0
Tot_Balls = 0
set Cn3=server.createobject("ADODB.connection")
set Rs3=server.createobject("ADODB.recordset")
Cn3.open dsn
sql3 = "select * from Hawk_Eye where (query_id = '" & result_query_id & "') and (run_id = '" & result_run_id & "')"
Rs3.open sql3, Cn3
if Rs3.eof <> true then
while not Rs3.eof
Tot_Speed_temp = Rs3("Speed_at_Release")
Tot_Speed = Tot_Speed + Tot_Speed_temp
Tot_Balls = Tot_Balls + 1
Rs3.movenext
wend
end if
set Rs3=nothing
Cn3.close
Speed_Per_Ball = Tot_Speed / Tot_Balls
End sub
%>
I was following the code from Link (http://www.webdeveloper.com/forum/showthread.php?t=22710)
Any ideas???