views:

480

answers:

3

I am trying to see if this can be done in classic ASP:

Dim myVar
myVar = <<< END
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
    <title>test</title>
</head>

<BODY>
END

I can do this in PHP, but I am not positivte if it can be done in ASP. Problem is I need to handle the HTML output via a variable, and I don't want to go through the HTML and convert " to ""

EDIT:

I've found that this is called HEREDOC syntax in PHP.

Since its been asked, what I am trying to do is store HTML type tags (which may contain ', " characters which would otherwise break myVar = "<stuff color="red">here</stuff>"

so I would need to fix it by replacing color="red" with color=""red""

PART OF THE PROBLEM:

I don't want to have to replace " with "" for the content as I assign it, I guess a HEREDOC syntax is not available for ASP classic.

OK FINE... :P

Since everyone is asking me WHY I am going about it this way, here is why, I have to support this old ASP code, I don't want to, but suddenly the scope of this old app changes that they want the contents (which used to be an HTML page) to be emailed, SO... I wanted to HEREDOC the HTML output, pass it to the mail function and have it email. Having said that, I know its sloppy, and I know it works better the other way, however this is what the job called for, I didn't want to re-write it, I just wanted to augment the output from HTML to HTML-EMAIL...

Hope that makes more sense ;)

A: 

I'm pretty sure you can't do exactly what you're asking here. It might help, however, if you explained what you're trying to do. There may be some other way.

update:

You could consider putting your HTML fragments into seperate files. This would allow you to define them without having to do any reformatting of the HTML. In a similar manner you could put them into a database or even into resource files.

I'm still not 100% clear why you want these HTML fragments defined as variables, but these approaches would work.

Martin Peck
Basically, I want to be able to store 'something' in a variable without fixing the `"` or any other character that might break the assignment.
Jakub
A: 

Hi Jakub -

The easiest thing to do would be to keep the HTML in a separate file, and then open that file using a TextStream object, reading the string into a variable.

Mark Bertenshaw
I thought about that, but how would I handle sections where I loop through a resultset of data? Unfortunetly this is age old asp classic that I need to fix up.
Jakub
You could load in multiple fragments from disk. There would be a header fragment (from <HTML> to the top of your <TABLE> or whatever), a row fragment, and then your footer fragment (from </TABLE> to the </HTML> tag.Having said that, I would be very interested to know what kind of code requires this kind of convoluted syntax. Why can't you include the HTML in the ASP file? My suggestion would certainly be slower.
Mark Bertenshaw
+1  A: 
Dewayne Christensen
I know about this, BUT, as you noted, I still have to search and replace `"` to `""` in the <html> tags.. :(
Jakub
Dewayne Christensen
That's why you get paid the big bucks.
Dewayne Christensen
@Dewayne: you can use either vbCrLf or vbNewLine - the latter is preferred as it will send either vbCrLf or vbCr as appropriate for the client.
AnonJr
Jakub