Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 23rd, 2009, 12:25 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You could do something like this:

joesref = reIn.Replace(joesref, "$1 " )

It would really help if you could tell us WHAT code is failing. Did you create the function that Old Pendant provided or are you using the inline style?

Which line of the code that he provided is failing?

-doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old March 23rd, 2009, 12:37 PM
Authorized User
 
Join Date: Dec 2005
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm using it inline, not as a function because I have to set the variable after I received a response from another webserver. The line of Old's code that's failing is:

Response.Write reIn.Replace( input, "$1 " )

Thanks.
 
Old March 23rd, 2009, 12:45 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Hmm. I am out of ideas. This code, as written (testd on IIS 6 and 7), outputs: A B C D E F G

vb Code:
<%
Dim input
Dim reIn
input = "ABCDEFG"
Set reIn = New RegExp
reIn.Pattern = "(.)"
reIn.Global = True
Response.Write reIn.Replace( input, "$1 " )
%>

Troubleshooting code that I can't see is a painstaking endevour. ;]

-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old March 23rd, 2009, 03:46 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

SO work around company policy.

PARAPHRASE your actual code by creating something that exhibits the same problem but doesn't give away any of how you are actually using this.

In my code, there's no SUB involved. BUT... But if you USED the code wrong, there could be an IMPLIED SUB.

As Doug showed you, in VBScript whenever you use a subroutine--NO MATTER IF IT IS CALLED SUB or FUNCTION, you can *NOT* use parens when you have two arguments unless you *USE* the subroutine *AS* a function.

SO you could have
Code:
Function Foo(a,b)
     ...
End Function

Foo(1,3) ' -- ERROR:  "Can't use parens when calling a sub"
dummyVariable = Foo(1,3) ' would work
CALL Foo(1,3) ' would work
Foo 1, 3 ' would work
So the solution *MIGHT* be as simple as either getting rid of your extra parens *OR* putting the keyword CALL in front.

But get around the company rules by posting some "parallel" code.

After all, that's what you did in your FIRST post in this thread, isn't it? Why can't you do that again?
 
Old March 23rd, 2009, 03:51 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

If you changed my code from
Code:
Response.Write reIn.Replace( input, "$1 " )
to just
Code:
reIn.Replace( input, "$1 " )
then you have done exactly as both Doug and I suspected.

And you could get rid of the error by coding ANY of my suggested fixes:
Code:
reIn.Replace input, "$1"
Call reIn.Replace( input, "$1")
dummy = reIn.Replace( input, "$1")
BUT NONE OF THOSE WILL HELP YOU!

I think you are under the impression that the code reIn.Replace is going to *CHANGE* the contents of the input variable. NO NO NO! NOT AT ALL!

If you WANTED that variable to be changed, you would need to code
Code:
input = reIn.Replace( input, "$1 " )
And now you *ARE* using the function *AS* a function, so no more complaints about the parentheses usage.

But next time, don't spend so much time spinning your wheels. If you can post a problem and show code, surely you can post an attempt at fixing the problem that includes code. Just make sure the code doesn't give away company secrets. (That probably aren't all that secret, anyway.)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace the string has comma with spaces? kumiko Classic ASP Basics 3 January 10th, 2008 06:41 PM
adding varchar string to hyperlink dgreep PHP Databases 1 February 19th, 2007 05:56 AM
adding multiple spaces otter606 Javascript 2 March 3rd, 2005 11:00 AM
Adding functionality to the String class? RobMeade BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 5 February 9th, 2005 02:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.