Classic Computer Magazine Archive COMPUTE! ISSUE 76 / SEPTEMBER 1986 / PAGE 86

Rapid Transfer

Buck Childress

The Commodore 64's BASIC has no built-in search-and-replace function, so renaming variables in a program can be a very time-consuming job. With this utility, you can easily rename any type of variable in a BASIC program. Though it's written in machine language for extra speed, no machine language knowledge is needed to use it.


No matter how well you plan ahead, nearly every BASIC programmer needs to modify his or her work from time to time. Renaming variables is one of the most tedious and exacting tasks you will face as a BASIC programmer. You must painstakingly comb every line of the program to insure that you have changed every reference to the variable involved. Should one reference be overlooked, the program will refuse to run correctly, if at all. The longer the program, the more tiresome the task becomes, and the greater the risk of introducing errors. The next time you find yourself in this situation, give "Rapid Transfer" a try. It automatically renames any variable you choose, whether string, numeric, integer, or array. It's easy to use, and gets the job done in a jiffy.

Getting Started

Type in the program as listed, then save a copy to disk or tape. To install Rapid Transfer, simply type RUN and press RETURN. The program automatically loads a machine language routine into the memory area beginning at location 50000. Since this memory zone isn't part of BASIC program space, you can load and save BASIC programs without interference.

Next, load the BASIC program you want to work on. To activate Rapid Transfer, type SYS 50000 and press RETURN. It begins by asking you for the old variable name—the name of an existing variable which you want to change. Type in this name, then press RETURN. At this point, you're asked to supply a new name for the variable. Should you happen to make a mistake while answering a prompt, press the INST/DEL key (pressing it twice will start you at the beginning).

You can enter up to ten characters for each variable name, in case you like to use extended names such as HOUSE$ or MATH%. If the variable you want to change is an integer or string, you will not be able to enter any additional characters after pressing the % or $ key (BASIC syntax doesn't allow it). Also, you can enter a number only after you've entered a letter (another BASIC syntax rule). Should you enter different types of variables, such as renaming a numeric variable with a string variable, Rapid Transfer displays the message TYPE MISMATCH. You'll then be given the option of going ahead with the transfer or starting over.

If the variable you want to change is an array, press the asterisk (*) key. You can do this at any time while you are entering the variable names, and it has to be done only once. Note that Rapid Transfer can tell when a variable is an array and responds accordingly. It is not necessary to enter the parentheses which ordinarily indicate an array—just enter the name itself. For example, to enter an array that you DIMension as A(20), you would enter A, not A( ).

After you press the asterisk key, the message ARRAY? begins flashing at the top of your screen. This is your prompt to enter the number of dimensions in the array. Enter 1, 2, or 3, depending on whether the array has one, two, or three dimensions. After you answer the prompt, the message stops flashing. If you make a mistake or want to cancel the array option, press the English pound (£) key. Rapid Transfer will not change an array variable to a nonarray variable, or vice versa, nor will it change the number of dimensions in an array.

After entering the new variable name and pressing RETURN, you'll see the message ARE YOU SURE? (Y/N). Press Y to proceed or N if you wish to reenter your choices.

Prescan For Name Conflicts

The first thing you'll notice when Rapid Transfer begins working is the line numbers of your program flashing at the top of the screen. Rapid Transfer is prescanning every line of the program to see whether it already contains a variable with the new name that you have chosen. If a name conflict is found. Rapid Transfer displays a warning message. If the variable is an array, an asterisk appears next to its name (a two-dimensional array has two asterisks, and so forth). After it finishes the prescan, Rapid Transfer displays the prompt ARE YOU SURE? (Y/N). If no name conflicts appeared, or if you wish to proceed despite the conflict, press Y. Press N if a conflict is found or if you simply change your mind.

Rapid Transfer now displays the lines of your program as it seeks out the old variables and renames them. If the old variable doesn't exist in your program. Rapid Transfer displays a warning message indicating that the designated variable can't be found. Again, array variable names are displayed with one, two, or three asterisks, depending on the number of dimensions in the array. When it's done, the program lets you continue with another change (press Y) or quit (press N).

Safety Features

Rapid Transfer has several built-in safety features to insure accurate operation. It won't change anything enclosed within quotation marks or anything which appears on a line following a REM or DATA statement. While scanning each line, it also checks for excessive length. If, for example, you decide to change the variable CO$ to COST$ and, as a result, one of the program lines will exceed the 80-character logical length. Rapid Transfer aborts operation and displays the line number where the excessive length occurred. It also displays that line as it currently appears in the program so that you can make any necessary adjustments.

In addition. Rapid Transfer can tell the difference between different kinds of variables. For example, let's say that you want to rename the numeric variable A to A1. Rapid Transfer will rename only the numeric variable A. It will not rename any integer, string, or array variables of the same name, nor will it inadvertently change a variable which happens to begin with A, such as AB. The same holds true for the other types of variables, including arrays. If you have a one-dimensional array named A, Rapid Transfer will not change a two- or three-dimensional array of the same name, or vice versa.

Rapid Transfer works equally well with extended variable names. If you have used HOUSE$ in a home budget program. Rapid Transfer will recognize it as HO$, exactly as the 64 does. The entire name is present in the program line, but only the first two characters are significant. So you can use and change extended variable names as much as you like, with variables of any type.

Rapid Transfer can be brought to a halt at any time by pressing the RUN/STOP key. Enter SYS 50000 to reactivate it.

Rapid Transfer

For instructions on entering this listing, please refer to "COMPUTE!'s Guide to Typing In Programs" in this issue of COMPUTE!.

GD 10 PRINT CHR$(147)CHR$(5)"LOADING AND CHECKING DATA LINE:":
      J=50000:L=45:C=11
GS 20 PRINT CHR$(19)TAB(31)L:PRINT
CG 30 FOR B=0 TO C:READ A:POKE J+B,A:X=X+A:NEXT B:READ A
DR 40 IF X<>A THEN PRINT "ERROR IN DATA LINE:"L:END
SJ 50 X=0:J=J+12:L=L+5:IF L<685 THEN 20
GQ 60 IF L=685 THEN C=9:GOTO 20
EE 70 PRINT "DATA OK AND LOADED...":PRINT:
      PRINT "SYS 50000 TO ACTIVATE...":END
HM 80 DATA 32,59,200,133,198,133,253,162,96,134,251,142,1793
GF 90 DATA 138,2,157,0,201,232,208,250,202,142,224,201,1957
PG 100 DATA 142,225,201,169,94,133,252,141,247,201,162,10,1977
HH 110 DATA 32,71,200,133,254,166,252,169,100,157,0,4,1538
JD 120 DATA 173,134,2,157,0,216,32,162,200,173,141,2,1392
AC 130 DATA 201,2,176,246,32,228,255,201,13,208,3,76,1641
DA 140 DATA 179,196,201,20,208,3,76,136,196,201,92,240,1748
AS 150 DATA 51,201,42,208,87,141,239,201,173,33,208,141,1725
GX 160 DATA 25,216,32,36,200,206,221,201,208,17,32,36,1430
ER 170 DATA 200,238,222,201,48,6,32,116,200,76,203,195,1737
DJ 180 DATA 32,110,200,206,248,201,32,162,200,32,228,255,1906
QC 190 DATA 201,92,208,11,169,0,141,239,201,32,110,200,1604
JD 200 DATA 76,247,195,201,49,144,206,201,52,176,202,141,1890
JP 210 DATA 25,4,56,233,49,141,234,201,32,116,200,141,1432
EK 220 DATA 25,216,140,222,201,76,134,195,201,36,240,4,1690
EB 230 DATA 201,37,208,31,166,251,48,14,174,96,201,240,1667
PA 240 DATA 236,141,253,201,141,254,201,76,34,196,174,192,2099
FR 250 DATA 201,240,222,141,255,201,133,254,76,90,196,166,2175
PC 260 DATA 254,224,10,144,13,240,2,176,204,162,88,32,1549
EM 270 DATA 71,200,230,254,208,195,201,48,144,191,201,58,2001
BF 280 DATA 176,16,174,96,201,164,251,16,3,174,192,201,1664
KA 290 DATA 224,0,240,173,208,8,201,65,144,167,201,91,1722
MA 300 DATA 176,163,230,254,166,251,157,0,201,230,251,48,2127
FM 310 DATA 12,174,236,201,224,2,176,15,238,236,201,208,1923
XS 320 DATA 10,174,237,201,224,2,176,3,238,237,201,32,1735
BM 330 DATA 210,255,230,252,165,251,141,247,201,76,121,195,2344
XF 340 DATA 174,247,201,16,112,166,211,32,210,255,202,208,2034
DA 350 DATA 250,142,192,201,142,237,201,142,247,201,142,255,2352
CR 360 DATA 201,169,145,32,53,200,169,192,162,27,160,174,1684
JM 370 DATA 133,251,132,252,76,116,195,166,252,173,33,208,1987
GC 380 DATA 157,0,216,173,96,201,240,197,166,251,16,226,1939
CD 390 DATA 173,192,201,240,188,141,208,201,173,193,201,141,2252
RF 400 DATA 209,201,169,0,141,138,2,141,98,201,157,0,1457
AA 410 DATA 201,173,254,201,205,255,201,240,5,162,44,32,1973
RC 420 DATA 71,200,162,64,32,71,200,32,162,200,32,42,1268
CB 430 DATA 200,201,25,240,67,201,39,208,242,76,80,195,1774
PB 440 DATA 173,251,201,208,26,162,96,32,82,200,173,254,1858
EM 450 DATA 201,240,8,205,97,201,240,3,32,210,255,32,1724
RP 460 DATA 93,200,162,117,76,33,197,162,112,32,71,200,1455
BM 470 DATA 162,130,32,71,200,32,162,200,32,42,200,201,1464
JE 480 DATA 25,240,202,201,39,208,242,169,0,133,198,96,1753
GX 490 DATA 141,235,201,169,1,162,8,141,240,201,142,241,1882
DG 500 DATA 201,32,59,200,133,198,168,173,240,201,174,241,2020
RP 510 DATA 201,133,253,134,254,32,216,199,177,253,208,14,2074
EX 520 DATA 173,243,201,208,155,238,243,201,141,252,201,76,2332
EC 530 DATA 60,197,32,216,199,177,253,170,32,216,199,177,1928
JA 540 DATA 253,142,249,201,141,250,201,32,205,189,169,32,2064
KD 550 DATA 32,210,255,32,216,199,169,201,133,252,169,96,1964
EP 560 DATA 174,243,201,208,2,169,208,133,251,162,0,142,1893
DK 570 DATA 228,201,142,231,201,142,242,201,173,232,201,240,2434
KM 580 DATA 6,142,232,201,142,252,201,161,253,240,28,32,1890
BJ 590 DATA 223,199,133,2,32,52,199,165,2,162,0,193,1362
SR 600 DATA 251,208,99,230,251,161,251,240,102,32,216,199,2240
RE 610 DATA 76,175,197,142,216,201,142,244,201,142,246,201,2183
CM 620 DATA 142,252,201,32,62,200,173,245,201,208,16,32,1764
RQ 630 DATA 216,199,165,253,166,254,141,240,201,142,241,201,2419
MG 640 DATA 76,73,197,142,245,201,173,249,201,172,250,201,2180
FG 650 DATA 205,224,201,208,5,204,225,201,240,221,141,224,2299
XJ 660 DATA 201,140,225,201,32,71,200,169,19,141,119,2,1520
FA 670 DATA 169,13,141,120,2,141,121,2,141,122,2,169,1143
DG 680 DATA 4,133,198,76,49,168,32,162,200,32,216,199,1469
DD 690 DATA 76,142,197,142,227,201,142,228,201,142,233,201,2132
SC 700 DATA 202,134,2,142,230,201,173,246,201,208,227,173,2139
HF 710 DATA 252,201,32,141,200,164,2,200,238,230,201,177,2038
EX 720 DATA 253,201,32,240,246,132,2,238,227,201,174,239,2185
RF 730 DATA 201,208,53,201,40,240,195,32,223,199,173,228,1993
XC 740 DATA 201,208,7,173,252,201,208,48,240,15,164,2,1719
MQ 750 DATA 200,177,253,201,32,240,249,132,2,201,40,240,1967
FR 760 DATA 165,32,24,200,205,232,201,208,84,173,232,201,1957
JE 770 DATA 208,82,206,230,201,76,224,198,201,40,240,32,1938
QA 780 EATA 32,223,199,173,252,201,240,61,173,227,201,201,2183
DG 790 DATA 2,144,162,173,97,201,174,243,201,208,3,173,1781
SJ 800 DATA 209,201,201,0,208,147,240,37,32,24,200,205,1704
RS 810 DATA 232,201,208,29,164,2,200,177,253,240,22,201,1929
BD 820 DATA 44,208,3,238,233,201,201,41,208,240,206,230,2053
HM 830 DATA 201,173,233,201,205,234,201,240,3,76,38,198,2003
PS 840 DATA 173,242,201,32,141,200,172,243,201,208,32,173,2018
EG 850 DATA 216,201,208,237,169,29,32,53,200,162,192,32,1731
JS 860 DATA 82,200,32,93,200,162,102,142,243,201,32,71,1560
HG 870 DATA 200,141,252,201,76,234,196,140,245,201,140,251,2277
HF 880 DATA 201,174,236,201,202,169,20,32,103,200,172,230,1940
PP 890 DATA 201,240,10,48,6,32,216,199,136,208,250,160,1706
KA 900 DATA 0,185,192,201,240,175,32,120,199,200,208,245,1997
FE 910 DATA 201,128,144,57,166,212,208,53,201,131,208,2,1711
RR 920 DATA 240,4,201,143,208,3,141,246,201,56,233,127,1803
RM 930 DATA 170,160,255,202,240,8,200,185,158,160,16,250,2004
HC 940 DATA 48,245,200,185,158,160,48,14,238,238,201,32,1767
JE 950 DATA 113,199,169,0,141,238,201,76,90,199,56,233,1715
EQ 960 DATA 128,201,32,240,3,238,242,201,174,244,201,48,1952
CC 970 DATA 11,208,30,166,211,224,79,144,3,238,244,201,1759
FH 980 DATA 174,243,201,208,13,201,34,208,8,173,216,201,1880
PK 990 DATA 73,1,141,216,201,96,76,210,255,173,238,201,1881
GH 1000 DATA 240,2,104,104,104,104,162,148,142,244,201,32,1587
QS 1010 DATA 71,200,174,249,201,173,250,201,32,205,189,169,2114
AE 1020 DATA 32,32,210,255,173,240,201,174,241,201,133,253,2145
RF 1030 DATA 134,254,169,4,133,251,164,251,177,253,240,14,2044
MR 1040 DATA 32,52,199,230,251,76,202,199,230,253,208,2,1934
JG 1050 DATA 230,254,96,164,212,240,5,160,0,76,17,200,1654
PD 1060 DATA 201,32,240,242,201,36,240,4,201,37,208,9,1651
SK 1070 DATA 141,228,201,141,232,201,76,13,200,201,48,144,1826
SC 1080 DATA 16,201,58,144,8,201,65,144,8,201,91,176,1313
KJ 1090 DATA 4,238,252,201,96,140,232,201,140,252,201,96,2053
RB 1100 DATA 173,255,201,174,243,201,240,3,173,254,201,96,2214
HA 1110 DATA 169,40,141,221,201,96,165,203,205,235,201,240,2117
FC 1120 DATA 249,141,235,201,96,32,210,255,76,210,255,32,1992
SH 1130 DATA 68,229,169,0,133,199,133,212,133,216,96,189,1777
JP 1140 DATA 177,200,240,250,32,210,255,232,208,245,189,0,2238
QR 1150 DATA 201,240,239,32,210,255,232,208,245,173,239,201,2475
GX 1160 DATA 240,228,174,234,201,169,42,32,210,255,202,16,2003
KE 1170 DATA 250,96,173,33,208,76,119,200,173,134,2,133,1597
SD 1180 DATA 2,162,96,160,5,189,177,200,153,18,4,165,1331
MK 1190 DATA 2,153,18,216,232,136,16,241,96,172,243,201,1726
PA 1200 DATA 208,6,205,237,201,76,155,200,205,236,201,240,2170
CJ 1210 DATA 239,104,104,76,38,198,32,225,255,208,229,104,1812
EM 1220 DATA 104,169,0,141,138,2,76,68,229,13,83,89,1112
HE 1230 DATA 83,53,48,53,48,53,0,13,13,79,76,68,587
EF 1240 DATA 32,86,65,82,73,65,66,76,69,63,32,0,709
AQ 1250 DATA 13,13,78,69,87,32,86,65,82,73,65,66,729
AF 1260 DATA 76,69,63,32,0,13,13,18,84,89,80,69,606
RH 1270 DATA 32,77,73,83,77,65,84,67,72,46,46,46,768
ME 1280 DATA 0,13,13,18,65,82,69,32,89,79,85,32,577
KE 1290 DATA 83,85,82,69,63,32,40,89,47,78,41,0,709
QP 1300 DATA 32,32,18,76,73,77,73,84,0,191,153,129,938
FG 1310 DATA 146,146,129,32,32,18,69,88,73,83,84,83,983
FJ 1320 DATA 0,68,79,78,69,0,32,32,18,78,79,84,617
EK 1330 DATA 32,70,79,85,78,68,0,13,13,67,79,78,662
PA 1340 DATA 84,73,78,85,69,63,32,40,89,47,78,41,779
HF 1350 DATA 0,13,18,69,88,67,69,83,83,73,86,69,718
QK 1360 DATA 32,76,69,78,71,84,72,13,13,0,508