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
RENUM utility BETA
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).
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).
RENUM utility BETA
- Attachments
-
- renum.prg
- BETA - v0.9
- (1.3 KiB) Downloaded 290 times
Re: RENUM utility BETA
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!
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!
Re: RENUM utility BETA
Also, a question... does this work as a shortened command, like reN or rE? Inquiring minds want to know.
Re: RENUM utility BETA
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
Re: RENUM utility BETA
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.
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.
Re: RENUM utility BETA
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.
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.
Re: RENUM utility BETA
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.
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.
Re: RENUM utility BETA
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.
Re: RENUM utility BETA
Just found a bug, if the hi bank is changed (POKE 0,x) after activating, causes a crash. Will fix that.
Re: RENUM utility BETA
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: 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.