Ever wanted to
change the variable names in your Atari BASIC program? Ever tried? It's very difficult and error prone to list each line of large programs for alteration, so here is a method which is very simple and very effective.
The first and most important step is to make a backup copy in case something goes wrong. It also helps if the program already works properly as debugging with new names is awkward. The next step is to enter Listing 1 - with your program loaded. If your program uses lines 15000 to 15020, simply relocate my routine. Listing 1 uses the variables I,B,J and C. If you do NOT use these variables in your program substitute numeric variables that you have used so that no extra variables are added to the Variable Name Table which is our target. If you do not have a printer, change
the 'P:' in line 15000 to 'E:' and get ready with CTRL-1, a pen and some paper. Type GOTO 15000 and a list of variables will be printed (or displayed - get scribbling). You will have a list something like this
In this example there are only five variables but you should of course have many more. You may notice that the
last character of each name has an ASCII code greater than 127, i.e.
it is inverse video. This is the 'End of Name' marker.
15010 FOR I=J TO B:C=PEEK(I):? #5;CHR$(C);:IF C>127 THEN ? #5
15020 NEXT I:CLOSE #5:END
Your next task is to give each variable its new name. It is imperative that each name is unique and this should be double checked - write the alphabet down the left side of a sheet of paper and list each variable against its initial letter. Some variables end in a dollar
sign '$' and some with a bracket '('. The new name for these must also end with the appropriate symbol as these represent strings and arrays so BASIC interprets data it has differently. All new names should be legal, don't use non alphanumeric characters or reserved words.
When you have decided on the new names, add up the total number of characters in each list If the new list is much smaller in characters you are safe but if they are nearly the same or the new list is longer, enter a, few new very long variables by typing
ABCDEFGHIJ etc. in direct mode until the length of the new variable names far exceeds the previous difference.
Now enter the second listing without deleting the first. Amend it if necessary as outlined above and
note that IN$ should be DIMensioned to about 50. Type GOTO 15050 and a number will appear followed by a question mark. You must now type in the first variable name. BASIC expects only the last character of the name to be over ATASCII 127 so do not enter any inverse text, the program will do the inverting. Before you press RETURN, make sure you have not made a mistake. If you have, edit it. If you spot an error after you have pressed RETURN press BREAK and then type GOTO 15050 again. You MUST start again as you can't do anything clever because the variable name table will be in a mess and could crash the system.
I,:INPUT IN$:FOR C=1 TO LEN(IN$):POKE I+C-1,ASC(IN$(C,C))+128*(C=LEN(IN$)):NEXT C
15070 I=I+LEN(IN$):IF I>B-10 THEN ? "[ESC,BELL]FIN"
15080 GOTO 15060
When you get to the end of your list, type in two CONTROL COMMAS, which will appear like hearts on the screen, followed by RETURN. When the ? appears again, press BREAK, type GOTO 15000 and
you will get the new list of variables. Check that these are alright and if not type GOTO 15050 and start again! If all is okay, LISTing the program will show the new version.
The final step is to delete lines 15000 to 15080, LIST the program to tape or disk and then type
NEW and ENTER it again. This corrects the BASIC pointers to the table and also its length. If no illegal variables were used, everything should now be finished, so (C)SAVE it. If duplicate names were used, previous references will now all refer to one variable so problems will occur.
One thing you may like to do is to have illegal variable names like (C)83 F.BLOGGS. To do this
you must enter it as MCM83FMBLOGGS initially and after you have LISTed and ENTERed it for SAVEing, type:
FOR I=PEEK(130)+PEEK(131)*256 TO
PEEK(132)+PEEK(133)*256:? I,CHR$(PEEK(I)):NEXT I
As the variables go past note the locations (numbers on the left) of the M's and when READY appears, POKE in the decimal numbers - from appendix C of the BASIC manual - for
each illegal character in place of the allotted M. Do not use numbers greater than 127. The program will SAVE, LOAD,
LIST and RUN properly but editing of lines with these variables will not be possible. Have fun!