Problems writing percent character

Discussion in 'ASP General' started by Simon Wigzell, Feb 16, 2005.

  1. I have written an asp funciton to write a 301 redirect. It gets the file
    name and the new desitination as arguments. I am doing this for hundreds of
    files so a script is more accurate than doing it manually and much faster, I
    thought. Problem is it chokes on the line:

    FileText = FileText & "%>" & vbcrlf

    Error message is:
    Microsoft VBScript compilation error '800a0409'

    Unterminated string constant

    /NewTest/TestRedirects/WriteRedirects.asp, line 58

    FileText = FileText & "
    -----------------------^It doesn't have any problem with FileText = FileText
    & "<%" & vbcrlf

    I've tried escaping it:

    FileText = FileText & "\%>" & vbcrlf

    but it chokes on the "\"

    How can I append "%>" to a string????

    Full function follows:

    function CreateRedirect(Filename,Destination)
    FullFilename = server.mappath(Filename)
    set fs = CreateObject("Scripting.FileSystemObject")
    set file = fs.OpenTextFile(FullFilename, 2, true)
    FileText = ""
    FileText = FileText & "<%" & vbcrlf
    FileText = FileText & "Response.Status = ""301 Moved Permanently""" &
    vbcrlf
    FileText = FileText & "Response.addheader ""Location"",""" & Destination
    & """ & vbcrlf
    FileText = FileText & "Response.End" & vbcrlf
    FileText = FileText & "%>" & vbcrlf
    file.WriteLine(FileText)
    file.Close()
    set fs = nothing
    end function
     
    Simon Wigzell, Feb 16, 2005
    #1
    1. Advertising

  2. Try with
    What is the content of FileText ?

    FileText = FileText & Chr(37) & ">" & vbcrlf
     
    Gérard Leclercq, Feb 16, 2005
    #2
    1. Advertising

  3. "Gérard Leclercq" <> wrote in message
    news:9MLQd.13257$-ops.be...
    >
    > Try with
    > What is the content of FileText ?
    >
    > FileText = FileText & Chr(37) & ">" & vbcrlf
    >
    >

    Thanks! That solved it.
     
    Simon Wigzell, Feb 16, 2005
    #3
  4. Simon Wigzell

    Evertjan. Guest

    Gérard Leclercq wrote on 16 feb 2005 in
    microsoft.public.inetserver.asp.general:
    > Try with
    > What is the content of FileText ?
    >
    > FileText = FileText & Chr(37) & ">" & vbcrlf



    FileText = FileText & "%" & ">" & vbcrlf

    Why can I never remember them ascii numbers?
    'cause they are American?

    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
     
    Evertjan., Feb 16, 2005
    #4
  5. Evertjan. wrote:
    > Why can I never remember them ascii numbers?
    > 'cause they are American?


    This American uses Arabic numerals for expressing ASCII numbers.



    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms. Please do not contact
    me directly or ask me to contact you directly for assistance. If your
    question is worth asking, it's worth posting.
     
    Dave Anderson, Feb 16, 2005
    #5
  6. Simon Wigzell

    Roland Hall Guest

    "Dave Anderson" wrote in message
    news:...
    : Evertjan. wrote:
    : > Why can I never remember them ascii numbers?
    : > 'cause they are American?
    :
    : This American uses Arabic numerals for expressing ASCII numbers.

    I'm using Italian (Roman) numerals with a lemon twist for expressing ASCII
    numbers in my champagne cocktail. (O:=

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Feb 17, 2005
    #6
    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. =?Utf-8?B?cGhpbGxpcA==?=

    Regexp and percent signs

    =?Utf-8?B?cGhpbGxpcA==?=, Sep 24, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    645
    =?Utf-8?B?cGhpbGxpcA==?=
    Sep 24, 2004
  2. =?Utf-8?B?Y2hhcmxpZXdlc3Q=?=

    How to: Convert DOUBLE to PERCENT?

    =?Utf-8?B?Y2hhcmxpZXdlc3Q=?=, Jul 12, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    33,276
    =?Utf-8?B?Y2hhcmxpZXdlc3Q=?=
    Jul 12, 2005
  3. Dmitri

    Percent JFormattedField

    Dmitri, Nov 22, 2004, in forum: Java
    Replies:
    2
    Views:
    1,942
    Dmitri
    Nov 23, 2004
  4. Mickey Segal
    Replies:
    76
    Views:
    1,740
    decent_john
    Feb 3, 2006
  5. Bill
    Replies:
    4
    Views:
    140
    Aaron Bertrand - MVP
    Aug 29, 2003
Loading...

Share This Page