Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handling double quotes with WriteLine

Status
Not open for further replies.

werosen1

Programmer
Mar 30, 2006
16
US
Greetings

I am trying to write a string to a file using the following:

dim ReportObject,ReportFile
set ReportObject=Server.CreateObject("Scripting.FileSystemObject")
set ReportFile=ReportObject.CreateTextFile(Server.MapPath("\reports\reportfile.asp"))
ReportFile.WriteLine("<%@ LANGUAGE="VBSCRIPT" %>")

Obviously it dies at the second double quote before VBSCRIPT.

Can someone tell me how to handle this?

Thanks,
Warren
 
Have you tried using the character code for the double quote? I think it is 34...

ReportFile.WriteLine("<%@ LANGUAGE=" & Chr(34) & "VBSCRIPT" & Chr(34) & " %>")

Another thing you can do is just escape the quote with another quote, some people like... and it is probably a tiny bit faster, but it looks funny to me so I do it the other way.
 
If I use the code you showed i get the following:

Microsoft VBScript compilation error '800a0409'

Unterminated string constant

/createreportfile.asp, line 1691

ReportFile.WriteLine("<%@ LANGUAGE=" & Chr(34) & "VBSCRIPT" & Chr(34) & "
 
The ASP tags you're trying to write to the file are seen as closing tags for the ASP that's executing. Try splitting it up a bit so the characters aren't contiguous in the code:
Code:
ReportFile.WriteLine "<" & "%@ LANGUAGE=" & Chr(34) & "VBSCRIPT" & Chr(34) & " %" & ">"

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top