Problems writing percent character

S

Simon Wigzell

I have written an asp funciton to write a 301 redirect. It gets the file
name and the new desitination as arguments. I am doing this for hundreds of
files so a script is more accurate than doing it manually and much faster, I
thought. Problem is it chokes on the line:

FileText = FileText & "%>" & vbcrlf

Error message is:
Microsoft VBScript compilation error '800a0409'

Unterminated string constant

/NewTest/TestRedirects/WriteRedirects.asp, line 58

FileText = FileText & "
-----------------------^It doesn't have any problem with FileText = FileText
& "<%" & vbcrlf

I've tried escaping it:

FileText = FileText & "\%>" & vbcrlf

but it chokes on the "\"

How can I append "%>" to a string????

Full function follows:

function CreateRedirect(Filename,Destination)
FullFilename = server.mappath(Filename)
set fs = CreateObject("Scripting.FileSystemObject")
set file = fs.OpenTextFile(FullFilename, 2, true)
FileText = ""
FileText = FileText & "<%" & vbcrlf
FileText = FileText & "Response.Status = ""301 Moved Permanently""" &
vbcrlf
FileText = FileText & "Response.addheader ""Location"",""" & Destination
& """ & vbcrlf
FileText = FileText & "Response.End" & vbcrlf
FileText = FileText & "%>" & vbcrlf
file.WriteLine(FileText)
file.Close()
set fs = nothing
end function
 
G

Gérard Leclercq

Try with
What is the content of FileText ?

FileText = FileText & Chr(37) & ">" & vbcrlf
 
E

Evertjan.

Gérard Leclercq wrote on 16 feb 2005 in
microsoft.public.inetserver.asp.general:
Try with
What is the content of FileText ?

FileText = FileText & Chr(37) & ">" & vbcrlf


FileText = FileText & "%" & ">" & vbcrlf

Why can I never remember them ascii numbers?
'cause they are American?
 
D

Dave Anderson

Evertjan. said:
Why can I never remember them ascii numbers?
'cause they are American?

This American uses Arabic numerals for expressing ASCII numbers.



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
R

Roland Hall

in message
: Evertjan. wrote:
: > Why can I never remember them ascii numbers?
: > 'cause they are American?
:
: This American uses Arabic numerals for expressing ASCII numbers.

I'm using Italian (Roman) numerals with a lemon twist for expressing ASCII
numbers in my champagne cocktail. (O:=

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top