Large BASIC programmes
Chris Hall (132) 3554 posts |
I occasionally have the need to use a BASIC programme longer than 65000 lines (more like 250000 lines). My solution is to give each line the number zero (and to spread around some lines with ‘item%=nnnn’ so that error reporting can indicate roughly where the error occurred). Although this works fine, I don’t think RISC OS BBC BASIC actually supports unnumbered lines (although the ABC compiler doesn’t support numbered lines!)? BBC BASIC for Windows does support unnumbered lines. |
Rick Murray (539) 13840 posts |
Would it work to break the program into LIBRARY pieces? Would this work around limitations? Steve? Help! :-) |
Chris Hall (132) 3554 posts |
It might. But it’s simpler to just have a single programme with 250000 lines all with line number zero. |
Steve Drain (222) 1620 posts |
BASIC can happily work with all lines numbered zero, but not if you have line references such as GOSUB and RESTORE. These are unlikely in modern programming, but as you know, you do not get line numbers in error reporting. I think a BASIC program of 250000 lines is a bit unwieldly, and it does seem a pity to loose the error reporting when it is quite simple to use LIBRARY. Surely you have code that is common to some of your programs that could be shared? There is no penalty in speed in using libraries, although overlays are different, but who would use those now?
I think there are line numbers, it is just that they are not shown, as you can do in StrongED, for instance. Perhaps the line numbers are removed when the runtime is produced. |
Chris Hall (132) 3554 posts |
I think a BASIC program of 250000 lines is a bit unwieldly I know, but the problem was a programme being machine generated where the size was not known until it had been created. (It was a dis-assembled Draw file with 100000’s of vector graphics.) All I needed to do was to make a few simple edits and run the programme, otherwise I didn’t need to read it! In BB4W you can simply add lines anywhere, with or without line numbers. However the programme will refuse to run unless the lines that are numbered occur in numerical order (this prevents more than one line having the same number and makes finding a numbered line simpler). You can renumber the programme or remove all line numbers. Commands like RESTORE+0 allow the current line to be referenced even though it is not (or may not be) numbered. |
Martin Avison (27) 1494 posts |
Is the generated code just executed sequentially? If it is not sequential but already split into PROC/FNs, just decide where to split between them. |
Chris Hall (132) 3554 posts |
It is entirely sequential (and I do have control) – but does call procedures in a (single) separate library programme. I could generate a new programme every 50000 lines or so and make each one a procedure called from a main program. In the vast majority of cases the generated programme is, however, short and this would look horribly complex. Just occasionally it turns out to be 100000s of lines. So the simple solution seemed to be to make the line numbers all zero, so that when a large programme is created it doesn’t generate an error. The user can always renumber a short programme to make it look more conventional. |