ASP ERROR: 'Cannot use parens when calling a Sub' 
Author Message
 ASP ERROR: 'Cannot use parens when calling a Sub'

I have an active server page that takes several strings and passes them
(one at a time) to a function that perfoms several replace operations.
When I run it, I get the following error:

   Microsoft VBScript compilation error '800a0414'

   Cannot use parens when calling a Sub

   /gibbs/csf/update_member.asp, line 10

   Replace(StringToFix, "'", "'")
   ----------------------------------^

Can someone please clue me in to what I'm doing wrong?  I've been
looking through my ASP/VBScript reference book, but I can't seem to find
anything.

Thanks,
Jason

----------------------------------------


-------- http://www.*-*-*.com/



Sun, 16 Sep 2001 03:00:00 GMT  
 ASP ERROR: 'Cannot use parens when calling a Sub'
I didn't see it specifically, so I'll take a guess...change:

Replace(StringToFix, "'", "'")

to

FixedString = Replace(StringToFix, "'", "'")

 - Mark

On Wed, 31 Mar 1999 00:41:18 -0500, Jason Gibbs

Quote:

>I have an active server page that takes several strings and passes them
>(one at a time) to a function that perfoms several replace operations.
>When I run it, I get the following error:

>   Microsoft VBScript compilation error '800a0414'

>   Cannot use parens when calling a Sub

>   /gibbs/csf/update_member.asp, line 10

>   Replace(StringToFix, "'", "'")
>   ----------------------------------^

>Can someone please clue me in to what I'm doing wrong?  I've been
>looking through my ASP/VBScript reference book, but I can't seem to find
>anything.

>Thanks,
>Jason

>----------------------------------------


>--------http://users.andassoc.com/gibbs/

You know what to remove.


Sun, 16 Sep 2001 03:00:00 GMT  
 ASP ERROR: 'Cannot use parens when calling a Sub'
or - obviously - to

    Replace StringToFix, "'", "'"

 - Reinhard



Sun, 16 Sep 2001 03:00:00 GMT  
 ASP ERROR: 'Cannot use parens when calling a Sub'
The error "can't use parens when calling a Sub", not surprisingly,
indicates that you have used parentheses when calling a sub, which is not
legal syntax.  My advice -- lose those parentheses.

The reason that this is not legal syntax is complicated and dumb, but that's
what VB does, so that's what VBScript does too.

Eric


Quote:
> I have an active server page that takes several strings and passes them
> (one at a time) to a function that perfoms several replace operations.
> When I run it, I get the following error:

>    Microsoft VBScript compilation error '800a0414'

>    Cannot use parens when calling a Sub

>    /gibbs/csf/update_member.asp, line 10

>    Replace(StringToFix, "'", "'")
>    ----------------------------------^

> Can someone please clue me in to what I'm doing wrong?  I've been
> looking through my ASP/VBScript reference book, but I can't seem to find
> anything.

> Thanks,
> Jason

> ----------------------------------------


> --------http://users.andassoc.com/gibbs/



Sun, 16 Sep 2001 03:00:00 GMT  
 ASP ERROR: 'Cannot use parens when calling a Sub'
Eric-

If parentheses are not allowed in subroutines and functions, what then
about operations, like Replace, which (it appears to me) require
parentheses?  The purpose of the function I wrote is to search a string
and replace certain characters (ie - "'", "|", etc) with the equivalent
html symbol codes, so they won't{*filter*}up things down the line.  I was
setting it up as a function so that I could perform the same operations
on several strings at various times.

Thanks for your help.
Jason


Quote:

> The error "can't use parens when calling a Sub", not surprisingly,
> indicates that you have used parentheses when calling a sub, which is not
> legal syntax.  My advice -- lose those parentheses.

> The reason that this is not legal syntax is complicated and dumb, but that's
> what VB does, so that's what VBScript does too.

> Eric



> > I have an active server page that takes several strings and passes them
> > (one at a time) to a function that perfoms several replace operations.
> > When I run it, I get the following error:

> >    Microsoft VBScript compilation error '800a0414'

> >    Cannot use parens when calling a Sub

> >    /gibbs/csf/update_member.asp, line 10

> >    Replace(StringToFix, "'", "'")
> >    ----------------------------------^

> > Can someone please clue me in to what I'm doing wrong?  I've been
> > looking through my ASP/VBScript reference book, but I can't seem to find
> > anything.

> > Thanks,
> > Jason

> > ----------------------------------------


> > -------- http://www.*-*-*.com/

--
----------------------------------------


-------- http://www.*-*-*.com/


Sun, 16 Sep 2001 03:00:00 GMT  
 ASP ERROR: 'Cannot use parens when calling a Sub'
The rule is:

If you are assigning to a return value or using the "call" keyword,
parentheses are _required_ around an argument list, otherwise they are
_forbidden_.

The reason for this confusing syntax is, well, complicated -- it has to do
with backwards compatibility with old versions of VB plus VB's odd
byref-vs-byval semantics.

So, you want to do one of:

x = foo(1,2)
foo 1, 2
call foo(1,2)

You want to avoid these, because they are all illegal.

x = foo 1, 2
foo (1, 2)
call foo 1, 2

If you do this:

foo(z)

that is legal, but it is _different_ from

foo z

The difference is that the former passes z by value, the latter passes z by
reference.  (Obviously, right?  :-)  )

Eric


Quote:
> Eric-

> If parentheses are not allowed in subroutines and functions, what then
> about operations, like Replace, which (it appears to me) require
> parentheses?  The purpose of the function I wrote is to search a string
> and replace certain characters (ie - "'", "|", etc) with the equivalent
> html symbol codes, so they won't{*filter*}up things down the line.  I was
> setting it up as a function so that I could perform the same operations
> on several strings at various times.

> Thanks for your help.
> Jason


> > The error "can't use parens when calling a Sub", not surprisingly,
> > indicates that you have used parentheses when calling a sub, which is
not
> > legal syntax.  My advice -- lose those parentheses.

> > The reason that this is not legal syntax is complicated and dumb, but
that's
> > what VB does, so that's what VBScript does too.

> > Eric



> > > I have an active server page that takes several strings and passes
them
> > > (one at a time) to a function that perfoms several replace operations.
> > > When I run it, I get the following error:

> > >    Microsoft VBScript compilation error '800a0414'

> > >    Cannot use parens when calling a Sub

> > >    /gibbs/csf/update_member.asp, line 10

> > >    Replace(StringToFix, "'", "'")
> > >    ----------------------------------^

> > > Can someone please clue me in to what I'm doing wrong?  I've been
> > > looking through my ASP/VBScript reference book, but I can't seem to
find
> > > anything.

> > > Thanks,
> > > Jason

> > > ----------------------------------------


> > > -------- http://www.*-*-*.com/

> --
> ----------------------------------------


> -------- http://www.*-*-*.com/



Sun, 16 Sep 2001 03:00:00 GMT  
 ASP ERROR: 'Cannot use parens when calling a Sub'
Eric-
I really appreciate the help, but I must admit that I'm still confused.
[I'm teaching myself VBScript, can you tell?  ;o)  ].  Anyway, perhaps
if I show you some of my code, you can enlighten me...


<%
FUNCTION fixString(ByRef StringToFix)
        Replace (StringToFix, "'", "&#39;")
        Replace (StringToFix, "|", "&#124;")
        --assorted other replace operations--
END FUNCTION

        --snip snip--

Message = fixString(Request.form("Message"))
Subject = fixString(Request.form("Subject"))
--etc--
%>

One of the first things I tried was removing the parentheses from the
Replace operations, but then the strings became null (or so it
appears).  Where am I going wrong?

Thanks again for your help.
-Jason


Quote:

> The rule is:

> If you are assigning to a return value or using the "call" keyword,
> parentheses are _required_ around an argument list, otherwise they are
> _forbidden_.

> The reason for this confusing syntax is, well, complicated -- it has to do
> with backwards compatibility with old versions of VB plus VB's odd
> byref-vs-byval semantics.

> So, you want to do one of:

> x = foo(1,2)
> foo 1, 2
> call foo(1,2)

> You want to avoid these, because they are all illegal.

> x = foo 1, 2
> foo (1, 2)
> call foo 1, 2

> If you do this:

> foo(z)

> that is legal, but it is _different_ from

> foo z

> The difference is that the former passes z by value, the latter passes z by
> reference.  (Obviously, right?  :-)  )

> Eric



Sun, 16 Sep 2001 03:00:00 GMT  
 ASP ERROR: 'Cannot use parens when calling a Sub'
Either (a) get rid of the parens, or (b) put the "call" keyword before the
"Replace".

Eric


Quote:
> Eric-
> I really appreciate the help, but I must admit that I'm still confused.
> [I'm teaching myself VBScript, can you tell?  ;o)  ].  Anyway, perhaps
> if I show you some of my code, you can enlighten me...


> <%
> FUNCTION fixString(ByRef StringToFix)
> Replace (StringToFix, "'", "&#39;")
> Replace (StringToFix, "|", "&#124;")
> --assorted other replace operations--
> END FUNCTION

> --snip snip--

> Message = fixString(Request.form("Message"))
> Subject = fixString(Request.form("Subject"))
> --etc--
> %>

> One of the first things I tried was removing the parentheses from the
> Replace operations, but then the strings became null (or so it
> appears).  Where am I going wrong?

> Thanks again for your help.
> -Jason


> > The rule is:

> > If you are assigning to a return value or using the "call" keyword,
> > parentheses are _required_ around an argument list, otherwise they are
> > _forbidden_.

> > The reason for this confusing syntax is, well, complicated -- it has to
do
> > with backwards compatibility with old versions of VB plus VB's odd
> > byref-vs-byval semantics.

> > So, you want to do one of:

> > x = foo(1,2)
> > foo 1, 2
> > call foo(1,2)

> > You want to avoid these, because they are all illegal.

> > x = foo 1, 2
> > foo (1, 2)
> > call foo 1, 2

> > If you do this:

> > foo(z)

> > that is legal, but it is _different_ from

> > foo z

> > The difference is that the former passes z by value, the latter passes z
by
> > reference.  (Obviously, right?  :-)  )

> > Eric



Mon, 17 Sep 2001 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Help with 'cannot use parens' error

2. Error:Cannot use parens when call Sub HELP

3. HELP: Cannot use parens when calling sub.

4. Run-time error '-2147221231 (80040111)': Automation error ClassFactory cannot supply requested class

5. VBA sub won't call a VB sub

6. error 'ASP 0115' Unexpected error

7. 'Cannot use parentheses when calling a sub'

8. Can't call a vbscript sub from ASPX html

9. error message: Expected 'Sub'

10. error using ActiveX DLL's with ASP

11. error using ActiveX DLL's with ASP

12. error 'ASP 0115'

 

 
Powered by phpBB® Forum Software