# Basic: how to split lines?

I may be spoiled by Perl 6 here, but how to I split a line?

   MsgBox( "abc" +
"xyz" +
"123", 1, "Split Test" )


Error: unexpected symbol CRLF

Many thanks, -T

edit retag close merge delete

Sort by » oldest newest most voted

Hello,

You can use a line feed or carriage return:

MsgBox  "abc" & chr(10) &  "xyz" & chr(10) & "123", 1, "Split Test"


or

MsgBox  "abc" & chr(13) &  "xyz" & chr(13) & "123", 1, "Split Test"

more

Sorry I was not clear enough about my question.

The purpose of the question was to break very long line up so I did not have to scroll to see the ends of the lines. I can do this is Perl 6 very easily, but this is not Perl 6. I just need to know how in LO Basic.

( 2018-12-01 06:16:50 +0200 )edit

Why are you using "&" instead of "+"? Any advantages of one over the other?

( 2018-12-01 06:16:58 +0200 )edit

+ is too easy to mistake for addition. In Python this can be legal.

Use underscore at end of line:

MsgBox( "abc" + _
"xyz" + _
"123", 1, "Split Test" )

( 2018-12-01 06:29:20 +0200 )edit

Quoting @ Todd2: "Why are you using "&" instead of "+"? Any advantages of one over the other?"
In my opinion no general advantages, but: I always use & for concatenation in Basic and in Calc as well to disambiguate and to avoid surprises due to automatic conversion.
See:

Sub test()
a = 0 & 2
b = "0" & 2
c = 0 + "2"
d = 0 & "2"
REM Inspect a, b, c, and d in the Basic IDE.
End Sub

( 2018-12-01 11:35:47 +0200 )edit

Underscores it is. Thank you!

I will have to think if "+" or "&" will confuse more or less with "add" and "bitwise AND"

( 2018-12-02 20:07:40 +0200 )edit

Works beautifully!

  RunStr    =  Thunderbird + " -compose to=" + Recipient + _
",subject=" + Subject + ",html,body='" + Body + _
"',attachment='" + TableFn + "," + Chartfn + "'"

( 2018-12-08 05:59:57 +0200 )edit

Neither + nor & can be used for bitwise Boolean conjunction in LibO Basic.

Sub Test
b = True
i = 11
j = 18
Print b AND i AND j, " : ", Cint(b AND i AND j)
Print b + i + j    , " : ", Cint(b + i + j)
Print b & i & j    , " : ", Cint(b & i & j)
End Sub

( 2018-12-08 11:50:55 +0200 )edit