Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

call sub error

Status
Not open for further replies.

LinuxKommy

Technical User
Apr 2, 2002
31
US
When i try to call a sub with one variable like

Mysub(V1)

it works fine, but when i use

Mysub(V1,V2,V3)

it tells me: Error: cannot use parentheses when calling a Sub.

why?

thanks
 
function should be used in this case

_________________________________________________________
$str = "sleep is good for you. sleep gives you the energy you need to function";
$Nstr = ereg_replace("sleep","coffee",$str); echo $Nstr;

onpnt2.gif
[/sub]
 
onpnt,
i changed it to a function, but it tells me the same thing. if it makes any difference, i am calling the sub from an onClick event of a button.

thanks
 
does it look somethign like this
<html>
<head>
<script language=&quot;vbscript&quot;>
Function myFun(a,b,c,d)
alert a & b & c & d
End Function
</script>
</head>
<body>
<form>
<input type=&quot;button&quot; value=&quot;test&quot; onClick=&quot;myFun 1,2,3,4&quot;>
</form>
</body>
</html>

_________________________________________________________
$str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
$Nstr = ereg_replace(&quot;sleep&quot;,&quot;coffee&quot;,$str); echo $Nstr;

onpnt2.gif
[/sub]
 
yes and no

mine looked like
<input type=&quot;button&quot; value=&quot;test&quot; onClick=&quot;myFun(1,2,3,4)&quot;>

boy i feel dumb :)

thanks again :)
 
don't feel dumb at all. this is a very common error. The reasoning is you have vbscript declared as the first language in the page probably. Thus the onClick is interputed as a vbscript event. IE does this. the first script tag it finds it reads the language and that language will be the first it defaults to for all event calls.

example would be to run this
<html>
<head>

<script language=&quot;javascript&quot;>
function myFun(a,b,c,d) {
alert(a + b + c + d);
}
</script>

<script language=&quot;vbscript&quot;>
Function myFun(a,b,c,d)
alert a & b & c & d
End Function
</script>

</head>
<body>
<form>
<input type=&quot;button&quot; value=&quot;test&quot; onClick=&quot;myFun(1,2,3,4)&quot;>
</form>
</body>
</html>

even knwoing that same call that errored for you is in there it will not give the error now when you click the button.

great thing to know when you get odd errors poping up with the two client languages in the same page.

_________________________________________________________
$str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
$Nstr = ereg_replace(&quot;sleep&quot;,&quot;coffee&quot;,$str); echo $Nstr;

onpnt2.gif
[/sub]
 
whoops! meant to cahnge the function names
<html>
<head>

<script language=&quot;javascript&quot;>
function myFun(a,b,c,d) {
alert(a + b + c + d);
}
</script>

<script language=&quot;vbscript&quot;>
Function myFun2(a,b,c,d)
alert a & b & c & d
End Function
</script>

</head>
<body>
<form>
<input type=&quot;button&quot; value=&quot;test&quot; onClick=&quot;myFun2(1,2,3,4)&quot;>
</form>
</body>
</html>

this is how I wanted it to look with the vbscript fucntions renamed but still no errors with ( )

_________________________________________________________
$str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
$Nstr = ereg_replace(&quot;sleep&quot;,&quot;coffee&quot;,$str); echo $Nstr;

onpnt2.gif
[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top