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
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