Thanks! I've only had a quick play, but that version seems to work fine on my short test program with the terminally space-padded DATA string.
SteveF wrote: ↑Tue Aug 10, 2021 11:12 pmabout stripping spaces from already tokenised input ... How useful do you/anyone think this would be?
I personally have never had the need to do that, so I can't say it's a feature I'm desperate for, but, on the other hand, I do think it would be nice (but perhaps not essential) if space-stripping worked on both tokenised and untokenised input alike.
SteveF wrote: ↑Tue Aug 10, 2021 11:12 pmI guess it wouldn't be too hard to operate on the tokenised representation of the program in memory to strip leading/trailing spaces.
If you're going down the road of more involved parsing, I'm tempted to mention a feature I've kind of been wishing for
for a while now: GOTO <label>, GOSUB <label>, and RESTORE <label>.
Would it be possible for those constructs to be implemented either as an option in basictool or in some sort of separate pre-processor for basictool? To be clear, what I'm proposing is that in a modern text-editor the user would be able to mark a subroutine by prefacing it with (say) %%myroutine%%, and then call it with something like GOSUB %%myroutine%% -- and then basictool or the pre-processor would take the plaintext BASIC program as input and the first thing that would be done is that the program would be given line-numbers and the labels would be converted to numbers as appropriate.
But actually, the more I think about it, the more I feel that maybe that sort of functionality really falls outside the scope of basictool, which I would summarise roughly as "bringing BASIC ROM utilities to the modern commandline". So this sort of thing probably isn't a good fit for basictool after all...
Still, it would be a useful thing to be able to do in one way or another because when you're writing and editing 8-bit BBC BASIC in a modern text-editor the one stumbling block that prevents you from being able to avoid using line-numbers entirely is the pesky ON ERROR problem. At some point -- usually when you're using filesystem commands, e.g. to load or save a savegame -- you'll want to trap a filesys error, and you'll then have to use ON ERROR, which clears the BASIC stack and forces you to use GOTO in order to recover without crashing. Therefore, you'll end up faffing around and adding line-numbers to code that otherwise could have been structured beautifully with PROCs instead of GOSUBs, and with nary a line-number in sight. Which is a shame. (I know Jonathan Harston has actually
implemented ON ERROR LOCAL for 8-bit BBC BASIC, but you may not always have the space to include the machine-code patch.)
And adding line-numbers makes it harder to re-order blocks of code because doing so now requires you to remove the line-numbers in your modern text-editor, rearrange the code, let BASIC tokenise and renumber it, reimport it into the text-editor, and then change all the arguments of any GOTOs and GOSUBs, etc., to their new renumbered values. And repeat the whole procedure every time you need to restructure parts of the prog. Quite a pain.