Gambas3 Code Layout

New to Gambas? Post your questions here. No question is too silly or too simple.
Post Reply
an_other
Posts: 2
Joined: Wednesday 3rd January 2024 6:43pm

Gambas3 Code Layout

Post by an_other »

How can I lay a long line of code out on two or more lines? I need to declare several long strings, which run off the right side of the page. I am sure I have seen a way to do this, but can't find it now I need it.
Many thanks for any advice, An.
vuott
Posts: 263
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: Gambas3 Code Layout

Post by vuott »

If you refer to alphanumeric character strings, you can break the string into two or more parts, enclosed by quotation marks.
For convenience you can also have each one followed by the "&" symbol.

Exemplum:
Dim s as String
s = "aaaa bbbb cccc ddd " &
"eeee ffff gggg hhhh iiiiii"
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
User avatar
BruceSteers
Posts: 1580
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Gambas3 Code Layout

Post by BruceSteers »

You can just use multiple strings and they will be joined.

Dim s As String 
s = "Some text, "
    "Some more text"



Note, there is no linefeed between the strings and you CANNOT have a void line.
ie.
Dim s As String 
s = "Some text, "

     "Some more text"

' that will error because the blank line

If at first you don't succeed , try doing something differently.
BruceS
User avatar
thatbruce
Posts: 168
Joined: Saturday 4th September 2021 11:29pm

Re: Gambas3 Code Layout

Post by thatbruce »

Have you got the line wrap option set off in the ide?
Have you ever noticed that software is never advertised using the adjective "spreadable".
an_other
Posts: 2
Joined: Wednesday 3rd January 2024 6:43pm

Re: Gambas3 Code Layout

Post by an_other »

Thanks for the suggestions, guys - Somehow I had the idea that the second line was preceded by something like a backslash, but of course I entirely missed the obvious - thanks again
Post Reply