Program Cleaner

Emulator and emulator development specific topics
Post Reply
Bill H
Posts: 163
Joined: Sat Nov 27, 2010 6:05 pm

Program Cleaner

Post by Bill H »

Before I write a quick and dirty PERL program, is there a CL utility that will take a text listing of a ZX81 program (aka the outout from zxtool) and:

1. Remove all unused line numbers and auto intent the code (say 4 spaces)
2. Replace used line numbers with labels in the style of zxtext2p (ie @label)

Bill H

Also if anyone wants to use ConTEXT http://www.contexteditor.org/ to develop basic code I am attaching a highlighter I wrote for it.
Attachments
ZX81basic.txt
ConTEXT ZX81 Highlighter
(5.81 KiB) Downloaded 306 times
Bill H
Posts: 163
Joined: Sat Nov 27, 2010 6:05 pm

Re: Program Cleaner

Post by Bill H »

Here is a quick and dirty Program cleaner. What it does it remove any unused line numbers and line numbers that are needed are converted to labels for use with zxtext2p

usage: zxclean source_file destination_file [indent value]

The source file is a text listing of a .P file (aka one created with zxtool), destination file is the finished file after cleaning. Indent value is the optional size of the left indent, if omited it will be set to 10 (if less than 10 it will be 10 also).

Any line numbers that are referenced in GOTO or GOSUB are changed to @L### where ### is the line number. It will not change any computed line numbers inside of a GOTO or GOSUB but you have to add a label to where the computed line was and also edit the computation to use a label.

Here is an example code snippet of before and after zxclean:

Code: Select all

   10 RAND
   20 GOSUB 5000
  100 REM MAIN LOOP
  110 LET P=INT (RND*M)+1
  120 GOSUB 6000
  130 GOSUB 6300
  140 LET Q$="PRESS (S) TO SPIN"
  150 LET R=14
  160 LET Q=1
  170 GOSUB 800
  180 GOSUB 700
  190 GOTO 7000

Code: Select all

          RAND
          GOSUB @L5000
          REM MAIN LOOP
          LET P=INT (RND*M)
          GOSUB @L6000
          GOSUB @L6300
@L140:
          LET Q$="PRESS (S) TO SPIN"
          LET R=14
          LET Q=1
          GOSUB @L800
          GOSUB @L700
          GOTO @L7000
@L200:
Attachments
zxclean.zip
ZX81 Basic Program Cleaner
(831.11 KiB) Downloaded 1127 times
MOB-i-L
Posts: 62
Joined: Mon Apr 19, 2010 12:13 am
Location: Lund, Skåne/Scania, Sweden
Contact:

Re: Program Cleaner

Post by MOB-i-L »

Bill H wrote:Here is a quick and dirty Program cleaner. What it does it remove any unused line numbers and line numbers that are needed are converted to labels for use with zxtext2p

usage: zxclean source_file destination_file [indent value]
This is just an exe-file for Windows or MSDOS. Could you publish the source? since I use Linux on Raspberry Pi.
Post Reply