Search code examples
asp-classic

Format to allow ASP Classic <% %> tags inside of a FileSystem object Writeline command


I have a script I am building that creates ASP Classic pages from form input.

I am using the file object to create the asp file. It is working as intended, however I am slightly perplexed how to embed ASP CLASSIC code into the string. The open tag works like this:

fname.WriteLine"<% DIM GENERIC_VAR"

This displays in the file properly, however the use of the close tag doesn't seem to want to work. Even my IDE is indicating a formatting issue. Usually in the instances I need to replace a " (double quote) a ' (single quote) will work, but in this case I get compile errors (Unterminated string constant) or the file doesn't create the line as expected. I know about doubling up "" but so far haven't had any luck. Thanks.

Side note as an example, I just need to be able to print this into the line of the file:

fname.WriteLine"%>"

Solution

  • openasp  = "<"
    openasp  = openasp & "% "
    closeasp = " %"
    closeasp = closeasp & ">"
    

    Set up the ASP tags like above. Then Wrap them in line as needed for example:

    fname.WriteLine openasp & "DIM VAR_NAME" & closeasp