My line numbering, label handling script

rje

Member
Nov 6, 2019
40
13
8
I wanted a convenient script that made Commodore BASIC 2.0 easier for me. In particular, something that handles LABELS and figures out line numbers for me, in a manner similar to C64LIST.

In short, C64LIST is sort of a transpiler: it lets you code BASIC with shortcuts, under the assumption that you won't really be doing editing on the target machine.

So I wrote a short script. It handles labels, but also removes comments from the source (in the name of space savings).

Here's a usage example. My test file looks like this:

Code:
; mytest.bas2 ... this is a test

{:mylabel} print "hello, world"
rem goto {:mylabel}
read a, b, c
print a, b, c
data 10, 20, 30

gosub {:ml2}
end

{:ml2} print "this is ml2"
return
I run it through my script simply:

Code:
perl basic-labelmaster.txt mytest.bas2
And it prints the output:

Code:
1 PRINT "HELLO, WORLD"
2 READ A, B, C
3 PRINT A, B, C
4 DATA 10, 20, 30
5 GOSUB 7
6 END
7 PRINT "THIS IS ML2"
8 RETURN
 

Attachments

Last edited:

rje

Member
Nov 6, 2019
40
13
8
It would be nice if I could figure out a way to direct-inject data from directives within the file...