Page 1 of 1

How to break lines of code?

Posted: Tue Mar 17, 2015 8:01 am
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

Re: How to break lines of code?

Posted: Tue Mar 17, 2015 8:04 am
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.

Re: How to break lines of code?

Posted: Tue Mar 17, 2015 8:08 am
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

Re: How to break lines of code?

Posted: Tue Mar 17, 2015 8:40 am
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

Re: How to break lines of code?

Posted: Tue Mar 17, 2015 9:53 am
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