Classic Computer Magazine Archive COMPUTE! ISSUE 51 / AUGUST 1984 / PAGE 119

64 Searcher

John Krause, Assistant Technical Editor and Michael Jacobi

"64 Searcher" is a time-saving utility that searches through your BASIC program and locates any character or string of characters that you choose. (This is a 64 version of VIC searcher that appeared in COMPUTE!, February 1983.)

When you're working on a long BASIC program, it pays to plan ahead. But it seems that no matter how hard you try, you can't keep track of everything in your program. Can I use H to store the high score, or is that variable already being used for something else? Where is this subroutine called from? You probably end up searching for a certain number or word hidden among scores of program lines.

"64 Searcher" allows you to spend less time searching and more time programming. You simply give it the string of characters to search for and it tells you the numbers of all lines in which the string appears. It can search 100 lines faster than it takes you to search one. It's fast because it's written in machine language. But you don't have to know machine language to use it.

Just LOAD it and RUN it, then LOAD your BASIC program. 64 Searcher doesn't use any BASIC memory, so you can work on your program normally. You can use 64 Searcher at any time by typing 0 followed by the string you want to find enclosed within either slashes or quotes, and hitting RETURN. This stores the string in your program as line 0. If your program already has a line 0, you will have to change that line number because the string must be the first line in the program.

Then type SYS49152 and hit RETURN. Instantly, you should see numbers appear on the screen. These are the line numbers that contain the string you specified. If no match is found, no numbers will be printed. If the string occurs more than once in a line, the line number is printed only once.

Because BASIC commands are stored differently from other characters in a program, there are two ways of specifying the search string. If the string is enclosed within slashes, BASIC commands are recognized as such. If the string is within quotes, it will be treated as a literal string of characters.

For example, to find the BASIC statement AND, line 0 should be:

0 /AND/

After entering SYS49152, 64 Searcher will find the AND in this line:

10 IF X AND Y THEN 50

but not in this line:

20 PRINT "X AND Y"

To find the AND in line 20 above, use quotes instead of slashes.

Remember to delete line 0 before saving or running your program.

64 Searcher

Refer to the "Automatic Proofreader" article before typing this program in.

10 FOR I = 49152 TO 49255 : READ J : K = K + J : POKEI,
   J : NEXT									: rem 66
20 IF K <> 16302 THEN PRINT "ERROR IN DATA STATEMENTS" : STOP   : rem 117
30 PRINT "{CLR} SYS 49152 TO SEARCH"					: rem 36
100 DATA 169, 1, 133, 251, 169, 8, 133, 252, 160, 0,177, 251,
    56, 229, 251, 56							: rem 80
110 DATA 233, 5, 141, 104, 192, 233, 2, 141, 105, 192, 160, 0,
    177, 251, 170, 200							: rem 142
120 DATA 177, 251, 240, 67, 133, 252, 134, 251, 160, 0, 177,
    251, 56, 229, 251, 170						: rem 17
130 DATA 202, 134, 2, 198, 2, 165, 2, 205, 104, 192, 48, 222,
    133, 253, 173, 105							: rem ll0
140 DATA 192, 133, 254, 164, 253, 177, 251, 164, 254, 217, 5,
    8, 208, 229, 198, 253							: rem 45
150 DATA 198, 254, 208, 239, 160, 2, 177, 251, 170, 200, 177,
    251, 32, 205, 189, 169						: rem 88
160 DATA 32, 32, 210, 255, 76, 26, 192, 96				: rem 190