One of the reasons I just wrote a renumberer in pure bash (actually I did it in awk first, then re-wrote in bash) was because RESEQ.100 has a bug, and is essentially unhackable/unfixable by a mere mortal like me.

I did the awk version initially just out of pure perverse fun. I really just wanted to renumber SECTOR.BA so that I could have room to insert lines and hack on that.

https://github.com/bkw777/BASIC_renumber

Now this can be messed with by myself or anyone else later to add new behavior or fix bugs. Like, how about a feature to take a single long multi-statement line and convert it into a multi-line gosub without breaking the rest of the program? Or say I've got a bug of my own still in there that shows up sometime way later when I'm not around to fix it.

I might try seeing if I can manage to grow it to an unpacker/packer. Expand packed code to insert spaces between statements and keywords and arguments, and replace short variable names with longer ones. That's all a bit ambitious though. For now I'm just pleased I have a working renumberer that even works better than RESEQ.100, not to mention about 50 times faster and more convenient, (well, being on-device would be a significant convenience)

The bug in RESEQ is this:

SECTOR.BA contains this line:
301 ONAGOSUB310,311,312,,,,316,317,318,319

RESEQ.100 produces:
990 ONAGOSUB1010,1020,1030,,,,316,317,318,319

While it should have produced:
990 ONAGOSUB1010,1020,1030,,,,1070,1080,1090,1100

IF you had the source to the machine-language part of RESEQ.100, AND you actually had a working set of tools and workflow to regenerate the machine language and then the basic loader from that, then it's probably a pretty simple correction. But me, looking at what I have in my hands all these years later after the author wrote it, which is just RESEQ.100 itself, it's essentially inscrutable and unfixable.

Put it this way, maybe it's technically fixable, probably Steve will fix it in his built-in version if he does it, but for me it was easier to write it over from scratch, twice.

Ok maybe saying "twice" is a stretch since, the bash version is essentially identical to the awk version. I did the awk one first, then pretty much just transcribed it into equivalent bash line by line. The job was essentially not an awk job in the first place. The part that is supposed to be the main part of an awk program only has 3 lines in it, 4 if you count the matching pattern, and all the real work is in the END{...} section, using ordinary programming that could have been done exactly the same way in any language.

One thing that made the awk version not-so-silly after all is, that awk script will probably still work in 20 years. But if I wrote it in say python or ruby, it might not work *next* year.

--
bkw


On 6/17/21 11:43 AM, Tom Wilson wrote:
There is actually a renumber feature in one of the option ROMs. I want to say it’s the Cleuseau ROM.  You can renumber programs, as well as so a few other useful things.

So there’s no need to add to REX. Just install that option ROM and use it when writing BASIC programs.

On Thu, Jun 17, 2021 at 7:46 AM Stephen Adolph <[email protected] <mailto:[email protected]>> wrote:

    Neither M100 nor T200 have a built in renumbering function for BASIC.
    (NEC does).

    Seems to me that it would be a nice feature to add to REX#/REXCPM.

    Here's what I am thinking
    1) base the implementation from James Yi's RESEQ.100/.200
    2) implementation would be from a CNTL-key sequence in the main menu
    - position cursor over a .BA program
    - CNTL-{not sure what key to use}
    - specify starting number, and increment, press [enter]

    It is not in scope in my opinion for REX Manager to intercept any
    function directly from BASIC, which I think would be ideal.    James
    Yi's solution was a CALL from BASIC to renumber; that would be
    possible but you would always have to remember the call.  Nicer to
    have a user interface, but it would need to be active at the M100
    menu like the REX Quick menu features.


    Anyhow, open to thoughts or suggestions, or other nice little
    functions to add.

    Steve

--
Tom Wilson
[email protected] <mailto:[email protected]>
(619)940-6311



--
bkw

Reply via email to