Navigation:  thinBasic language > Operators > Compound operators >

Multi line strings

Previous pageReturn to chapter overviewNext page

 

Multi line strings assignment

 

Multi line strings are a fringe feature of programming languages. They are very rarely needed, so a lot of languages don't support them at all. And even when a language does support them, most programmers are not even aware of that. How often have you seen something like this in real code:

 

  DIM myStr AS STRING = "This is a thiNBasic

                         multiline string

                         just because I can!"

 

To simplify assignment of multi line text strings to string variables, thinBasic support 2 distinct ways:

1.double quote multi line
2.RAWTEXT keyword

 

1. Double quote multi line

 

To use this method just set a double quote at the beginning of the multi line string and than set another double quote char at the end of the string in a different line of the code. thinBasic will join all the lines found between the 2 double quotes.

 

Example:

  DIM MyString AS STRING = "<r><![CDATA[

 

        The text string goes here.  Since this is a XML CDATA section,

        stuff like <> work fine too, even if definitely invalid XML.

 

      ]]></r>"

 

Important: if you want to use single quote inside in multi line string as real char, just start with multi line string with a single quote, than enter a new line, type your multi line string and terminate it again with a single quote in a new line.

 

Example of double quotes inside multi line string:

  DIM MyString AS STRING

  MyString = "

        <r><![CDATA[

 

        "The text string goes here.  Since this is a XML CDATA section,

        stuff like <> work fine too, even if definitely invalid XML."

 

      ]]></r>

      "

 

2. RAWTEXT keyword

 

To use this method use RAWTEXT / END RAWTEXT keywords pairs block to enclose a multi line string.

 

Example:

  DIM MyString AS STRING = RAWTEXT

        <r><![CDATA[

 

        The text string goes here.  Since this is a XML CDATA section,

        stuff like <> work fine too, even if definitely invalid XML.

 

      ]]></r>

    END RAWTEXT

 

Rules for using RAWTEXT / END RAWTEXT 

1.in case RAWTEXT is an assignment, it MUST begin on the same line of the assignment
2.no line continuation sign before RAWTEXT
3.after RAWTEXT there MUST be a a new line
4.END RAWTEXT MUST be on a line without any other text