Search For PET And Apple II Plus
Michael Erperstorfer
Vienna, Austria
It isn't necessary to understand machine language to add this useful search utility to your library of programs. Just type in the BASIC loader program and it will build the machine language routine for you. There are versions here for Apple II Plus, and both Upgrade and 4.0 PET/CBM BASICs.
Here is a useful utility program, Search, which enables you to find any string or number of BASIC keyword within a BASIC program. For example, if you've written a large program and want to find out all the places where a variable, NAME$, appears, or all examples of GOSUB – use Search. It will print out all line numbers where it finds the target.
To start the search, you type in a new BASIC line at line zero and follow it with a colon and the target of your search. To look for NAME$:
0 : NAME$
To be able to look for numbers, the first character of line zero is ignored (that's why the colon is necessary. To look for the number 102, you would type:
0 : 102
Program 1 is for the Apple II Plus. You can type the & key and hit RETURN because this is easier than typing CALL 768 every time you want to initiate a search. (The machine language routine must be linked at first, before any searches, with CALL 768.)
For PET/CBM 4.0 BASIC users, Program 2 will create the machine language routine which can then be used by typing in SYS 864 and hitting RETURN. PET/CBM Upgrade BASIC users should make the change to line 972 as indicated in Program 3.
Program 1.
10 REM FIND FOR APPLE II PLUS 700 FOR ADRES = 768 TO 900 : READ DATTA : POKE ADRES, DATTA : NEXT ADRES 768 DATA 169, 76, 141, 245, 3, 169 774 DATA 16, 141, 246, 3, 169, 3 780 DATA 141, 247, 3, 96, 162, 0 786 DATA 173, 1, 8, 133, 1, 173 792 DATA 2, 8, 133, 2, 160, 0 798 DATA 177, 1, 208, 6, 200, 177 804 DATA 1, 208, 1, 96, 160, 0 810 DATA 177, 1, 133, 3, 200, 177 816 DATA 1, 133, 4, 200, 177, 1 822 DATA 133, 117, 200, 177, 1, 133 828 DATA 118, 165, 1, 24, 105, 4 834 DATA 133, 1, 165, 2, 105, 0 840 DATA 133, 2, 160, 0, 177, 1 846 DATA 240, 28, 205, 6, 8, 240 852 DATA 4, 200, 76, 196, 3, 162 858 DATA 0, 232, 200, 189, 6, 8 864 DATA 240, 7, 209, 1, 240, 245 870 DATA 76, 76, 3, 32, 119, 3 876 DATA 165, 3, 133, 1, 165, 4 882 DATA 133, 2, 76, 28, 3, 169 888 DATA 163, 32, 253, 251, 32, 32 894 DATA 237, 169, 160, 32, 253, 251 900 DATA 96
Program 2.
10 REM FIND FOR 4.0 BASIC 800 FOR ADRES = 864 TO 980 : READ DATTA : POKE ADRES, DATTA : NEXT ADRES 864 DATA 162, 0, 173, 1, 4, 133 870 DATA 193, 173, 2, 4, 133, 194 876 DATA 160, 0, 177, 193, 208, 6 882 DATA 200, 177, 193, 208, 1, 96 888 DATA 160, 0, 177, 193, 133, 195 894 DATA 200, 177, 193, 133, 196, 200 900 DATA 177, 193, 133, 54, 200, 177 906 DATA 193, 133, 55, 165, 193, 24 912 DATA 105, 4, 133, 193, 165, 194 918 DATA 105, 0, 133, 194, 160, 0 924 DATA 177, 193, 240, 28, 205, 6 930 DATA 4, 240, 4, 200, 76, 156 936 DATA 3, 162, 0, 232, 200, 189 942 DATA 6, 4, 240, 7, 209, 193 948 DATA 240, 245, 76, 156, 3, 32 954 DATA 199, 3, 165, 195, 133, 193 960 DATA 165, 196, 133, 194, 76, 108 966 DATA 3, 169, 35, 32, 210, 255 972 DATA 32, 127, 207, 169, 32, 32 978 DATA 210, 255, 96
Program 3.
972 DATA 32, 213, 220, 169, 32, 32