PDA

View Full Version : displaying quotation marks


Brad
12-16-2002, 11:54 AM
Hi, I need to be able to display quotation marks, and write them to a file. I've been successfully using the Writeline TextStream method, but some lines i need to write out have things in quotation marks, which need to be there for functionality purposes.

such a line is:
Ascend-Ip-Pool-Definition="44 10.139.255.88 1"

This would be inserted thusly:

f.writeline(" Ascend-Ip-Pool-Definition="44 10.139.255.88 1"")

But, obviously, ASP doesn't like the use of a quotation inside the quotation marks. Is there any way round this ?

Thanks,
Brad.

Leeus
12-16-2002, 02:15 PM
Use single quotes, try

f.writeline(" Ascend-Ip-Pool-Definition='44 10.139.255.88 1'")

glenngv
12-18-2002, 08:40 AM
escaping double-quote in ASP-VBScript is done by doubling it:

f.writeline("Ascend-Ip-Pool-Definition=""44 10.139.255.88 1""")


if you are using ASP-JScript, you need to use backslash:

f.writeline("Ascend-Ip-Pool-Definition=\"44 10.139.255.88 1\"");

Brad
12-18-2002, 09:19 AM
Brilliant,

Thanks very much for both your suggestions - the ""jfiej"" (double quotes) worked best for what I need !

Thanks again,
Brad.

whammy
12-19-2002, 12:19 AM
For the record, I MUCH prefer to use glenngv's method (well, not really his method, but his suggestion!) as well.

This keeps your syntax the same when you are viewing text or HTML, which looks much neater and less confusing.

It's also quite easy to understand once you get the hang of it... just comment any double quote with another (inside a response.write or WriteLine statement, that is).

For future reference, say you were going to use ASP to output this HTML, and want to insert a value to this field server-side:

<input type="hidden" name="myfield" value="" />

This is easily done (keeping the syntax intact) like so:


<%
Response.Write("<input type=""hidden"" name=""myfield"" value=""" & myfield & """ />" & vbCrLf)
%>


I bolded the spot where the double quotes "break out" of the response.write statement to include an imaginary variable (and you need additional quotes in that case).

The vbCrLf just adds a carriage return/line feed to the HTML output so you can still read it easily when you view the HTML page source. FYI this is unnecessary when using VBScript with FileSystemObject's WriteLine method, since the carriage return is automatically added. :)

That's a simple example of course, most ASP developers would simply output the variable (in this case) in HTML like so - it all depends on what you're doing:


<input type="hidden" name="myfield" value="<% = myfield %>" />


Hopefully that will make it more clear, if not to you, than perhaps to others that may read this thread. :)