How to break lines of code?

Post Reply
Dmoser22
Posts: 4
Joined: Sun Nov 02, 2014 6:26 am
My devices: iPad, iPhone, Windows

How to break lines of code?

Post by Dmoser22 »

Is there a way to continue a long line of code across multiple physical lines? If so, it's hidden pretty well in the documentation because I couldn't find it. If not, could you add one please?

Thanks,

-djm

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: How to break lines of code?

Post by Mr. Kibernetik »

In BASIC it is not possible to separate single code line into several physical lines if this code does not support multi-line syntax.
But there is no need to do it - long line automatically wraps into several lines of code if it does not fit into single line.

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: How to break lines of code?

Post by Mr. Kibernetik »

About multi-line syntax:
some commands can be naturally coded in multiple lines.

For example:

IF a=b THEN do_something ELSE do_another_stuff

can be coded as:

IF a=b THEN
do_something
ELSE
do_another_stuff
END IF

Dmoser22
Posts: 4
Joined: Sun Nov 02, 2014 6:26 am
My devices: iPad, iPhone, Windows

Re: How to break lines of code?

Post by Dmoser22 »

Thanks for the quick reply! My problem is that I have (for example) something like:

WHILE <very long and convoluted Booloean expression involving nested ANDs and ORs and references to multidimensional arrays, etc.>
' do some stuff
END WHILE

It'd be nice if I could split that WHILE condition to format it in a more readable way, but I understand that SB isn't implemented that way. I guess I could do it just by inserting spaces and letting it wrap, but that's kind of gross. No problem; I just wanted to know.

Kudos in general for a really excellent interpreter!

-djm

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: How to break lines of code?

Post by Mr. Kibernetik »

Thank you!

As for me, complex logical constructions I usually split into parts like that:

IF some_complex_expression THEN p1=1 ELSE p1=0
IF another_complex_expression THEN p2=1 ELSE p2=0
IF p1 OR p2 THEN do_what_needed

Post Reply