The use of variables, the VAL function, and the CODE function will allow you to save almost 2000 bytes as done below. Actually, more could be saved with more variables, but I limited it to the most useful values.
First change line 9996:
9996 DIM d$(VAL "28020"): LET p=VAL "20": LET O=NOT PI: LET U=SGN PI: LET G=VAL "7": LET J=VAL "15": LET F=VAL "4": LET d$( TO P)="*SEARCH IS COMPLETE*": LET a$="ALL": LET c$="": FOR x=U TO J: LET c$=c$+CHR$ x:NEXT x: LET s=0
The letter “0” stands for the number zero. Instead of using LET O=0 which takes 9 bytes I use LET O=NOT PI which takes just 5 bytes. For the same reason I use LET U=SGN PI instead of LET U=1. Another possibility would be to use INT PI instead of the number 3. You can use these directly in your own programs for considerable sayings. Using VAL instead of just a number in the other variables saves 2 bytes each. If you are adding this to a file you are presently using, you will need to enter O=0, U=1, F=4, G=7, and J=15 as direct commands as well.
Now go through each line of the program and change every reference to the number 0 to the letter O, each number 1 to the letter U, etc. Also replace the number 2 with U+U, 3 with F-U or INT PI, 5 with F+U, 6 with G-U, 8 with G+U, 11 with F+G, 14 with G+G, 16 with J+U, and 30 with J+J. It is a tedious task but it will provide BIG savings which allows you to maintain full capacity even with all these additions. Also, you can replace other numbers with CODES. For example, the number 32 is the code for a space so the number 32 can be replaced with CODE ” “. For example: Instead of FOR X=1 TO 32 you would use FOR X=U TO CODE ” ” which saves 8 bytes. Using CODE does make the program more difficult to follow and the savings are smaller so you may not want to do it. However, you should use VAL which can be used with any number. Instead of RANDOMIZE USR 64731 just use RANDOMIZE USER VAL “64731”. Each time you use VAL you save 2 bytes. With so many numbers in the program it really mounts up. Using a variable saves up to 6 bytes (but usually 5). Be careful about confusing a lower case “L”, that is “1”, with the number 1.
The disadvantage of using these techniques is that the program slows down. In a BASIC program this could become obvious, but since most of the sections of PRO/FILE are in machine code the difference in speed is negligible. Without a disk drive for fast loading and saving, I feel it is much more important to have as much capacity as possible. An exception is in lines 5010 through 5103. These lines handle the process of editing new or old files and the use of variables, etc will slightly reduce the speed you can type at so it may be wise to leave those lines alone. Also remember to leave 9990 and 9991 as is.
Please note that most of the program lines printed in this newsletter are written without these techniques in case you choose not to use them. Of course, if you don’t use them you will have to reduce the size of D$ considerably. If you are using them then adjust each line accordingly.
Products
Downloadable Media
Image Gallery
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.