Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Calling VBScript functions from ASP
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Kristabel
New Member

United Kingdom
83 Posts

Posted - 23 March 2001 :  04:48:02  Show Profile  Visit Kristabel's Homepage
Hi,

I want to call a VBScript function to encode a string (basically it does a series of 'replaces') but I need to do it from within ASP and I will then write the encoded string to the appropriate part of the page.

My code is this:

             strContent = trim(Request.Form("strContent"))
strContent = ENCODE(strContent)


but I keep getting either 'variable undefined: ENCODE' (which is weird because ENCODE is the function name, not a variable); or I get a type mismatch. I have tried removing the 'strContent =' from the second line but that doesn't work either.

Any ideas?

'Live, love and learn'

davemaxwell
Access 2000 Support Moderator

USA
3020 Posts

Posted - 23 March 2001 :  07:03:19  Show Profile  Visit davemaxwell's Homepage  Send davemaxwell an AOL message  Send davemaxwell an ICQ Message  Send davemaxwell a Yahoo! Message
Is this what you're looking for?? Server.URLEncode(fString)

Dave Maxwell
--------------
Proud to be a "World Class" Knucklehead
Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 23 March 2001 :  10:35:42  Show Profile
Try renaming your function just in case encode is a reserved word. Use option explicit. Your function should look something like this:

function Encode(strContent)
..
..
Encode = strContent
end function


You could get a type mismatch in your code if you don't pass the form data (if you call the page without submitting the form). In that case Request.Form("strContent") will be empty and cause an error when you try to trim it.


======
Doug G
======
Go to Top of Page

Kristabel
New Member

United Kingdom
83 Posts

Posted - 23 March 2001 :  11:08:57  Show Profile  Visit Kristabel's Homepage
Thanks both of you.

I wasn't trying to do URLEncode - I was using a function to do multiple replaces on a string because I thought a function would be a good way to prevent duplication all over the site. I can see why you thought that though - I should have named the function something different.

Thanks Doug - my friend here actually suggested the very same thing and it worked. Unfortunately I have since abandoned the idea because to pass the string I have to do replaces to remove various characters (such as quotes and linefeeds) so it sort of defeats the object of the function to minimise code!

Thanks again!

'Live, love and learn'
Go to Top of Page

gor
Retired Admin

Netherlands
5511 Posts

Posted - 23 March 2001 :  11:38:42  Show Profile  Visit gor's Homepage
Why is that ? You can just pass the string with all the characters to the function and (if needed) remove those characters there.
There are no limitations to the characters that a string passed as a parameter to a VBScript can contain.

Pierre
Go to Top of Page

Kristabel
New Member

United Kingdom
83 Posts

Posted - 25 March 2001 :  07:46:10  Show Profile  Visit Kristabel's Homepage
I thought that but it worked when I passed strings such as 'This is my content', but when I tried to pass the actual data (e.g. news articles with unusual characters and lots of single and double quotes) I got errors that corresponded with the point at which the first quote was.

'Live, love and learn'
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.24 seconds. Powered By: Snitz Forums 2000 Version 3.4.07