RENUM utility BETA

Talk about your programs in progress. Discuss how to implement features, etc.
Forum rules
This section is for testing Commander X16 programs and programs related to the CX16 for other platforms (compilers, data conversion tools, etc.)

Feel free to post works in progress, test builds, prototypes, and tech demos.

Finished works go in the Downloads category. Don't forget to add a hashtag (#) and the version number your program was meant to run on. (ie: #R41).
novemix
Posts: 18
Joined: Wed Jan 27, 2021 10:47 pm

File Download RENUM utility BETA

Post by novemix »

Hi everyone!
If you're interested, please BETA test this BASIC renumbering utility.
load with:
LOAD"RENUM.PRG",8,1
SYS $A000
NEW
then load the BASIC program you'd like to renumber and do
RENUM [start [,][increment]
It will default to 100 and 10 or to whatever was last specified.

It loads to and uses whatever hi memory bank is currently selected, so make sure you don't have anything there you don't want to lose.

Let me know what issues you run into, (DM's fine, here or Discord) and if you can, share the BASIC program you're trying to renumber.

Thanks!
Mark
Attachments
renum.prg
BETA - v0.9
(1.3 KiB) Downloaded 290 times
TomXP411
Posts: 1781
Joined: Tue May 19, 2020 8:49 pm

Re: RENUM utility BETA

Post by TomXP411 »

Hi, Mark. This looks like it will be very useful: I actually heavily rely on the renumber function in other BASIC interpreters, and I'm glad to see someone tackle that for Commander BASIC.

Since this is a beta test, I've moved it over to the WIP section. When you're confident that this is in a "release ready" state, feel free to upload it to the Development Tools subforum in the download section. While you're at it, please remember to use a hashtag to mark it with #R41, so we know it's meant to work with the R41 emulator/ROM combo.

Thanks!
TomXP411
Posts: 1781
Joined: Tue May 19, 2020 8:49 pm

Re: RENUM utility BETA

Post by TomXP411 »

Also, a question... does this work as a shortened command, like reN or rE? Inquiring minds want to know.
novemix
Posts: 18
Joined: Wed Jan 27, 2021 10:47 pm

Re: RENUM utility BETA

Post by novemix »

TomXP411 wrote: Wed Jan 18, 2023 10:23 pm Also, a question... does this work as a shortened command, like reN or rE? Inquiring minds want to know.
Not currently, but should be an easy add. I'm not actually extending basic (so it's not runnable from within a BASIC program, but that wouldn't make sense anyway). I'm hooking the IERROR vector, and checking for RENUM in the input buffer. So an abbreviation could be looked for as well. But I dunno, rE is technically 3 keypresses, so that's only a savings of 2 keypresses vs. RENUM.

On further thought, I'm thinking why not just shorten it to one character? R probably, or a punctuation symbol much like DOS wedge commands.

edit: input buffer rather than keyboard buffer
TomXP411
Posts: 1781
Joined: Tue May 19, 2020 8:49 pm

Re: RENUM utility BETA

Post by TomXP411 »

Hmm.

It would have to be reN, since rE is ambiguous (RESTORE, RETURN).

A couple of other things I've noticed, just looking at the description:

I'm wondering if a BASIC loader would work to do the SYS and NEW automatically, something like this...

10 IF L=1 THEN 40
20 POKE 0,63:REM 255 IF 2MB
30 L=1:LOAD "RENUM.PRG",8,1
40 SYS $A000
50 NEW


Since LOAD (including with ,8,1) automatically restarts the program, lines 10 and 20 are there to set up a flag, then use that flag to bypass the loading when the program restarts.

Also, I set the bank to 63, the highest bank available on a stock Commander X16. You can use 255 if you have a 2MB model. This keeps the renumber tool out of the way of the high memory banks, in case a program uses high memory for something else.
TomXP411
Posts: 1781
Joined: Tue May 19, 2020 8:49 pm

Re: RENUM utility BETA

Post by TomXP411 »

Yes, after testing, the renum loader works. This loads the renumber program into $A000, starts it, and then uses NEW to kill itself.

Also, the RENUM seems to work. I've only done something simple, so far, but I'll test it more thoroughly later with GOTO, GOSUB, ON GOTO, ON GOSUB, and line numbers in quotes.

However, since this lives in banked memory, anything that changes the bank will instantly kill BASIC and send the computer into the ML monitor. This isn't a problem for simple BASIC programs, but it definitely is if a program uses high memory.

It might be worth it to add something to kill the hook, such as RENUM KILL, or something.
novemix
Posts: 18
Joined: Wed Jan 27, 2021 10:47 pm

Re: RENUM utility BETA

Post by novemix »

having to do a NEW is a relic of loading with ,8,1 and it setting the end of basic pointers. So subsequent commands will give an OUT OF MEMORY error.

If a BASIC program is already in memory, doing a NEW and then an OLD should work.

Alternatively I could have it load with a BASIC stub and relocate itself to make it easier on the end user.
novemix
Posts: 18
Joined: Wed Jan 27, 2021 10:47 pm

Re: RENUM utility BETA

Post by novemix »

TomXP411 wrote: Wed Jan 18, 2023 11:46 pm Also, the RENUM seems to work. I've only done something simple, so far, but I'll test it more thoroughly later with GOTO, GOSUB, ON GOTO, ON GOSUB, and line numbers in quotes.
Hmm, don't think I considered line numbers in quotes, where would that normally be valid?

edit: Or, I think you mean just making sure it doesn't clobber random numbers contained in quotes? If so, cool.
novemix
Posts: 18
Joined: Wed Jan 27, 2021 10:47 pm

Re: RENUM utility BETA

Post by novemix »

Just found a bug, if the hi bank is changed (POKE 0,x) after activating, causes a crash. Will fix that.
TomXP411
Posts: 1781
Joined: Tue May 19, 2020 8:49 pm

Re: RENUM utility BETA

Post by TomXP411 »

novemix wrote: Wed Jan 18, 2023 11:54 pm
TomXP411 wrote: Wed Jan 18, 2023 11:46 pm Also, the RENUM seems to work. I've only done something simple, so far, but I'll test it more thoroughly later with GOTO, GOSUB, ON GOTO, ON GOSUB, and line numbers in quotes.
Hmm, don't think I considered line numbers in quotes, where would that normally be valid?
Consider any situation where someone might write a number as part of a quoted string.

It could be as simple as PRINT "I AM 10 YEARS OLD".
^ Now this example does not actually get changed, presumably because the GOTO token doesn't precede the 10.
However, if I do this...
10 PRINT I AM <REVERSE-SHIFT-I>10 YEARS OLD"
Then we get:
Screenshot 2023-01-18 160542.png
Screenshot 2023-01-18 160542.png (2.98 KiB) Viewed 4464 times
This is a pretty obscure use case, and $89 is the PETSCII value for the F2 key, so it's not like it's likely to be anything a user would ever type in a program. So you can probably safely ignore this.

So far, unless I do something like change banks while the program is running, I haven't seen anything too weird happening.
Post Reply