write <% and %> to file in asp

Discussion in 'ASP General' started by Mark, Aug 18, 2003.

  1. Mark

    Mark Guest

    Hi,
    I try to create a file, but failure.
    My code like is:

    <%
    dim fs
    dim tfile
    strNum = """1005"""
    strInfolink = "snum = " & strSiteNum

    set fs=Server.CreateObject("Scripting.FileSystemObject")
    set tfile=fs.CreateTextFile("D:\Inetpub\wwwroot\html\infolink.asp")
    tfile.WriteLine("<%")
    tfile.WriteLine(strInfolink)
    tfile.WriteLine("%>")
    tfile.close
    set tfile=nothing
    set fs=nothing
    %>


    Microsoft VBScript compilation error '800a0409'

    Unterminated string constant

    /html/testing.asp, line 28

    tfile.WriteLine("
    -----------------^



    The problem is '<%', if I take this out, everything is fine.
    Thanks.


    --
    Mark
    Mark, Aug 18, 2003
    #1
    1. Advertising

  2. Add a second % sign in both lines.

    Mike Ober.

    "Mark" <> wrote in message
    news:%...
    > Hi,
    > I try to create a file, but failure.
    > My code like is:
    >
    > <%
    > dim fs
    > dim tfile
    > strNum = """1005"""
    > strInfolink = "snum = " & strSiteNum
    >
    > set fs=Server.CreateObject("Scripting.FileSystemObject")
    > set tfile=fs.CreateTextFile("D:\Inetpub\wwwroot\html\infolink.asp")
    > tfile.WriteLine("<%")
    > tfile.WriteLine(strInfolink)
    > tfile.WriteLine("%>")
    > tfile.close
    > set tfile=nothing
    > set fs=nothing
    > %>
    >
    >
    > Microsoft VBScript compilation error '800a0409'
    >
    > Unterminated string constant
    >
    > /html/testing.asp, line 28
    >
    > tfile.WriteLine("
    > -----------------^
    >
    >
    >
    > The problem is '<%', if I take this out, everything is fine.
    > Thanks.
    >
    >
    > --
    > Mark
    >
    >
    Michael D. Ober, Aug 18, 2003
    #2
    1. Advertising

  3. Give this a try Mark...

    tfile.WriteLine(chr(60) & "%")
    tfile.WriteLine(strInfolink)
    tfile.WriteLine("%" & chr(62))

    Cheers!

    Anthony Sullivan

    "Mark" <> wrote in message
    news:%...
    > Hi,
    > I try to create a file, but failure.
    > My code like is:
    >
    > <%
    > dim fs
    > dim tfile
    > strNum = """1005"""
    > strInfolink = "snum = " & strSiteNum
    >
    > set fs=Server.CreateObject("Scripting.FileSystemObject")
    > set tfile=fs.CreateTextFile("D:\Inetpub\wwwroot\html\infolink.asp")
    > tfile.WriteLine("<%")
    > tfile.WriteLine(strInfolink)
    > tfile.WriteLine("%>")
    > tfile.close
    > set tfile=nothing
    > set fs=nothing
    > %>
    >
    >
    > Microsoft VBScript compilation error '800a0409'
    >
    > Unterminated string constant
    >
    > /html/testing.asp, line 28
    >
    > tfile.WriteLine("
    > -----------------^
    >
    >
    >
    > The problem is '<%', if I take this out, everything is fine.
    > Thanks.
    >
    >
    > --
    > Mark
    >
    >
    Anthony Sullivan, Aug 18, 2003
    #3
  4. Even better.

    Cheers!

    Anthony Sullivan

    "Michael D. Ober" <obermd-@-alum-mit-edu-nospam> wrote in message
    news:8i60b.19$...
    > Add a second % sign in both lines.
    >
    > Mike Ober.
    >
    > "Mark" <> wrote in message
    > news:%...
    > > Hi,
    > > I try to create a file, but failure.
    > > My code like is:
    > >
    > > <%
    > > dim fs
    > > dim tfile
    > > strNum = """1005"""
    > > strInfolink = "snum = " & strSiteNum
    > >
    > > set fs=Server.CreateObject("Scripting.FileSystemObject")
    > > set tfile=fs.CreateTextFile("D:\Inetpub\wwwroot\html\infolink.asp")
    > > tfile.WriteLine("<%")
    > > tfile.WriteLine(strInfolink)
    > > tfile.WriteLine("%>")
    > > tfile.close
    > > set tfile=nothing
    > > set fs=nothing
    > > %>
    > >
    > >
    > > Microsoft VBScript compilation error '800a0409'
    > >
    > > Unterminated string constant
    > >
    > > /html/testing.asp, line 28
    > >
    > > tfile.WriteLine("
    > > -----------------^
    > >
    > >
    > >
    > > The problem is '<%', if I take this out, everything is fine.
    > > Thanks.
    > >
    > >
    > > --
    > > Mark
    > >
    > >

    >
    >
    Anthony Sullivan, Aug 18, 2003
    #4
  5. > tfile.WriteLine("<%")

    tfile.writeline "<" & "%"
    Aaron Bertrand - MVP, Aug 18, 2003
    #5
  6. Mark

    Mark Guest

    Thanks All
    Mark








    "Mark" <> wrote in message
    news:#...
    > Hi,
    > I try to create a file, but failure.
    > My code like is:
    >
    > <%
    > dim fs
    > dim tfile
    > strNum = """1005"""
    > strInfolink = "snum = " & strSiteNum
    >
    > set fs=Server.CreateObject("Scripting.FileSystemObject")
    > set tfile=fs.CreateTextFile("D:\Inetpub\wwwroot\html\infolink.asp")
    > tfile.WriteLine("<%")
    > tfile.WriteLine(strInfolink)
    > tfile.WriteLine("%>")
    > tfile.close
    > set tfile=nothing
    > set fs=nothing
    > %>
    >
    >
    > Microsoft VBScript compilation error '800a0409'
    >
    > Unterminated string constant
    >
    > /html/testing.asp, line 28
    >
    > tfile.WriteLine("
    > -----------------^
    >
    >
    >
    > The problem is '<%', if I take this out, everything is fine.
    > Thanks.
    >
    >
    > --
    > Mark
    >
    >
    Mark, Aug 18, 2003
    #6
  7. > took a long time to process and still not working.

    Maybe you could tell us what "not working" means...
    Aaron Bertrand - MVP, Aug 18, 2003
    #7
  8. Mark

    John Davis Guest

    The file is not produced. I type http://localhost/createfile.asp in address
    bar, and the status bar doesn't move but sounds like IIS engine is trying to
    process the file but failed.

    "Aaron Bertrand - MVP" <> wrote in message
    news:...
    > > took a long time to process and still not working.

    >
    > Maybe you could tell us what "not working" means...
    >
    >
    John Davis, Aug 18, 2003
    #8
  9. Mark

    Bob Lehmann Guest

    <<<<but sounds like IIS engine is trying to process the file but failed>>>>
    So, what exactly does that sound like?

    vroooommm, vroooommm, sputter, cough, clunk?

    :>)

    Bob Lehmann

    "John Davis" <> wrote in message
    news:...
    > The file is not produced. I type http://localhost/createfile.asp in

    address
    > bar, and the status bar doesn't move but sounds like IIS engine is trying

    to
    > process the file but failed.
    >
    > "Aaron Bertrand - MVP" <> wrote in message
    > news:...
    > > > took a long time to process and still not working.

    > >
    > > Maybe you could tell us what "not working" means...
    > >
    > >

    >
    >
    Bob Lehmann, Aug 18, 2003
    #9
  10. Why do you think it's a syntax issue? Do you have the Norton Virus?
    http://www.aspfaq.com/2180




    "John Davis" <> wrote in message
    news:...
    > The file is not produced. I type http://localhost/createfile.asp in

    address
    > bar, and the status bar doesn't move but sounds like IIS engine is trying

    to
    > process the file but failed.
    >
    > "Aaron Bertrand - MVP" <> wrote in message
    > news:...
    > > > took a long time to process and still not working.

    > >
    > > Maybe you could tell us what "not working" means...
    > >
    > >

    >
    >
    Aaron Bertrand - MVP, Aug 18, 2003
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Hansen
    Replies:
    1
    Views:
    369
    Joona I Palaste
    Aug 24, 2003
  2. Peter Hansen
    Replies:
    1
    Views:
    410
    Joona I Palaste
    Aug 24, 2003
  3. scad
    Replies:
    4
    Views:
    941
    James Kanze
    May 28, 2009
  4. Iulian Ilea
    Replies:
    1
    Views:
    292
    pcx99
    Dec 21, 2006
  5. Tim Chase
    Replies:
    0
    Views:
    85
    Tim Chase
    Dec 16, 2013
Loading...

Share This Page