LB Booster
Programming >> Compatibility with LB4 >> 'Line too long' error http://lbb.conforums.com/index.cgi?board=compatibility&action=display&num=1469282188 'Line too long' error
Post by Richard Russell on Jul 23rd, 2016, 1:56pm
I have received a report of LBB issuing the 'Line too long' error, whilst LB runs the program successfully. As documented in the LBB Help File, this error can result from a DATA statement exceeding about 250 characters in length. There may be other obscure situations in which it can arise, but again only if the line is very long.
I wonder what leads people to write programs with such long lines. In my youth (!), the standard maximum line length was what would fit across the paper roll in a teletype machine: about 80 characters (often quoted as 78 printing characters plus the CRLF line termination).
Of course with a scrollable screen display this is no longer such a relevant limit (although I still like to create hardcopy printouts occasionally) but I find programs hard to read if I have to scroll them horizontally. One obvious reason is that you can no longer see by how much the code is indented, and indentation is often used to indicate program structure.
So I like to stick to a maximum line length of 80-100 characters even today, and as a result I never encounter the 'Line too long' error myself. I am therefore relatively unsympathetic to those who report this as a compatibility issue, and am tempted to suggest that writing code with very long lines is a sign of an untidy mind - which can lead to untidy and poorly-structured code.
But I would be interested in other people's opinions. Do you write code with very long lines (including DATA statements), and if so why?
Richard.
Re: 'Line too long' error
Post by RNBW on Jul 23rd, 2016, 3:04pm
I agree entirely. There it's nothing more frustrating than having to scroll backwards and forwards to read code.
It's one of the things I don't like about C/C++. Most of the programs I have come across have large indentations and it it's not long before the whole code is off the page.
Like you, I come from the era when code was limited to about 78 chars/line and I still try to keep it somewhere in this region whenever possible. Re: 'Line too long' error
Post by Richard Russell on Jul 23rd, 2016, 3:59pm
It's one of the things I don't like about C/C++. Most of the programs I have come across have large indentations and it it's not long before the whole code is off the page.
At least with C/C++, like BASIC, indentation is optional and is treated as whitespace as far as the language's syntax is concerned. With Python, however, indentation is critical to the syntax and must be consistently used otherwise the function of the code may change. This is one reason why I don't share the current enthusiasm for Python being used instead of BASIC as a beginners' language.
Richard.
Re: 'Line too long' error
Post by RNBW on Jul 23rd, 2016, 4:48pm
I've no experience of Python. It sounds like one to avoid. Is indentation automatic in the editors, or do you have to do it yourself. If the latter, its wide open to error.
The languages I like to look at are LBB, Freebasic, Purebasic and Free Pascal, with a little C/C++ (although I don't profess to understand C/C++). I think I'll stick with them.
Ray.
Re: 'Line too long' error
Post by tsh73 on Jul 24th, 2016, 08:54am
Code:
But I would be interested in other people's opinions. Do you write code with very long lines (including DATA statements), and if so why?
Was it actually code written by a person? I've seen program that puts other files into huge DATA lines. And reasons for it to be huge is 1) nobody supposed to read that anyway 2) it works in JB/LB, so why bother splitting strings.
Re: 'Line too long' error
Post by Richard Russell on Jul 24th, 2016, 09:35am
it works in JB/LB, so why bother splitting strings.
Why bother? Here are a few reasons:
Whether it appears to work is not the whole story, what matters is whether it's permitted by the LB docs. Do they state anywhere what the maximum length of a program line is?
A Liberty BASIC program is stored as a plain-text (.BAS) file, which you may want to manipulate - edit, print etc. - using other programs designed to work with plain text files. Many (for example Notepad) have a maximum line length.
Even if the DATA statements are not intended to be read by a human, the rest of the program presumably is. If you want a hardcopy version to browse, it's easier to print the entire program than just part of it.
Is there any guarantee that LB 5, in the unlikely event of it ever being released, will support very long lines?
The "precautionary principle": don't take unnecessary risks if they are easily avoidable.
If the DATA statements are generated automatically, it's probably just as easy to make them a sensible length than ridiculously long. So rather than ask "why bother?" I'd want to ask "why not?".
Richard. Re: 'Line too long' error
Post by tsh73 on Jul 24th, 2016, 12:06pm
here's an example of program that churns out big data lines Small scribble editor It happened that splitting long lines was not so obvious as just start another DATA line. That's because then I started, problem of long lines never came to my mind.
It looks like it was last change in the program. So it was changed for purely cosmetic reasons.
Re: 'Line too long' error
Post by Jack Kelly on Jul 24th, 2016, 5:24pm
I too try to avoid long code lines that require the horizontal scroll bar. No problem using the underscore continuation character when necessary. I sometimes overlook the problem if the line is just a few characters too long, although I never print out the code.
This brings to mind a similar question I had recently. Is there any limit to the length of a string?
Re: 'Line too long' error
Post by Richard Russell on Jul 24th, 2016, 8:14pm
In LBB strings are limited in length only by the amount of available memory (heap). It's hard to predict what the limit will be in practice because it depends on how much memory is being used by other objects (e.g. arrays) and how much is unavailable (e.g. string garbage).
You can use the LBB debugger to find the current heap usage, so subtracting that from the initial allocation (usually 500 Mbytes, unless reduced by an INI file setting) will give you a rough idea of the available memory.