Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiline String In Classic Asp

is there any possiblity to get multiline string in classic asp (I think vbscript is the language)?

I want a multiline string like in python or groovy:

def str = """hello I am a multiline string"""

I searched a lot but didn't find a solution.

Workarounds are welcome too.

BTW: I had in javascript the same problem and solved it back in time with a function saved in a variable. This function had a multiline comment in it so I could through everything away except the comment using regex.

Something like this:

var multilinestr = function() {
/*
hello
I am a multiline
string
*/
}

And after Regex I got a String which contains:

hello
I am a multiline
string

Thank you.

Edit:

I think I missed a very important point. My client is you using something like a "pre processor" for his scripts. It looks like this:

Dim str 
str = "<%std_text%>"

The "pre processor" exchanges "<%std_text%>" with a text which comes from a Database. But this text have breaks in it so I can't just put a '" & vbNewline ' to the end of line. This means after "pre processing" it looks like this:

Dim str 
str = "hello 
I am a multiline
string"

Is there anyway to get this "text" in a string?

If I could write something like this (groovy):

def multistr = """<%std_text%>"""

after "pre processing":

def multistr = """hello
I am a multiline
string"""

It would be great!

like image 719
OemerA Avatar asked Dec 16 '09 14:12

OemerA


1 Answers

python:

text = """"
hello world
this is some text
"""

vbscript:

text = "" & vbcrlf &_
"hello world" & vbcrlf &_
"this is some text" & vbcrlf

You can also write a custom stringbuffer class etc.

with new StringBuffer
    .writeline "hello world"
    .writeline "this is some text"
    result = .as_string
end with

Just KISS... I mean a 'preprocessor' for a scripting language? That doesn't sound good....

If you really need to use the preprocessor (i18n?) than you will need to modify it such to replace all line breaks by " & vbcrlf & ".

like image 122
Joost Moesker Avatar answered Sep 27 '22 23:09

Joost Moesker