Ask Your Question
0

Basic: how to split lines?

asked 2018-12-01 04:51:55 +0200

Todd2 gravatar image

updated 2018-12-01 16:09:24 +0200

erAck gravatar image

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 flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2018-12-01 05:43:23 +0200

Ratslinger gravatar image

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"
edit flag offensive delete link more

Comments

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.

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

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

Todd2 gravatar imageTodd2 ( 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" )
Ratslinger gravatar imageRatslinger ( 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
Lupp gravatar imageLupp ( 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"

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

Works beautifully!

  RunStr    =  Thunderbird + " -compose to=" + Recipient + _
               ",subject=" + Subject + ",html,body='" + Body + _
               "',attachment='" + TableFn + "," + Chartfn + "'"
Todd2 gravatar imageTodd2 ( 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
Lupp gravatar imageLupp ( 2018-12-08 11:50:55 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-12-01 04:51:55 +0200

Seen: 62 times

Last updated: Dec 01 '18