Multi-line string in an If statement

Author Message
wikiterra

  • Total Posts : 2
  • Scores: 0
  • Reward points : 0
  • Joined: 2/10/2009
  • Status: offline
Multi-line string in an If statement Tuesday, February 10, 2009 2:42 AM (permalink)
0
Okay here's the deal. I'm working in a situation where my company is using vbscript during a phase of server side scripting.

One phase that occurs earlier than the vbscript prints variables directly into the vbscript. So we have something that looks like this:

If "<%some html code that will be inserted%>" <> "" Then
SomeVariable = SomeValue
End If


The problem occurs when the code to be inserted spans multiple lines. For example:

<p>One paragraph.</p>

<p>Another paragraph.</p>



Will get inserted, causing the following vbscript to be executed:


If "<p>One paragraph.</p>

<p>Another paragraph.</p>" <> "" Then
some_variable = some_value
End If



Since the code is being printed in, it doesn't preserve the newline characters, causing an Unterminated string constant error.

Okay--now my question: is there anything in vbscript that is equivalent to python's triple quotes (""") that allow multiple lines to be treated as one single string?

ie (in python):


"""
This is one line.

This is another line.

But it's all part of the same string.
"""



I've been scouring google, and I haven't gotten anywhere, or maybe there's a term that I don't know that I haven't searched for.
 
#1
    webber123456

    • Total Posts : 58
    • Scores: 0
    • Reward points : 0
    • Joined: 9/20/2007
    • Status: offline
    RE: Multi-line string in an If statement Tuesday, February 10, 2009 6:57 AM (permalink)
    0
    since you are checking for an empty value why not use this :
    <%
    dim temp = "some html code that will be inserted"
    If  len(trim(temp))  >  0 Then
    SomeVariable = SomeValue
    End If

    %>
     
    #2
      wikiterra

      • Total Posts : 2
      • Scores: 0
      • Reward points : 0
      • Joined: 2/10/2009
      • Status: offline
      RE: Multi-line string in an If statement Tuesday, February 10, 2009 7:15 AM (permalink)
      0
      The problem with that is

      dim temp= "<%some html code that will be inserted%>"

      will become

      dim temp= "<p>One paragraph.</p>

      <p>Another paragraph.</p>"

      which will still result in an error, since it expects the quote at the end of the line...
      <message edited by wikiterra on Tuesday, February 10, 2009 7:31 AM>
       
      #3
        webber123456

        • Total Posts : 58
        • Scores: 0
        • Reward points : 0
        • Joined: 9/20/2007
        • Status: offline
        RE: Multi-line string in an If statement Wednesday, February 11, 2009 5:55 AM (permalink)
        0
        how are you passing in the html ?

        it won't throw an error if it comes through as a variable .


         
        #4

          Online Bookmarks Sharing: Share/Bookmark

          Jump to:

          Current active users

          There are 0 members and 1 guests.

          Icon Legend and Permission

          • New Messages
          • No New Messages
          • Hot Topic w/ New Messages
          • Hot Topic w/o New Messages
          • Locked w/ New Messages
          • Locked w/o New Messages
          • Read Message
          • Post New Thread
          • Reply to message
          • Post New Poll
          • Submit Vote
          • Post reward post
          • Delete my own posts
          • Delete my own threads
          • Rate post

          2000-2012 ASPPlayground.NET Forum Version 3.9