"Global search" for programmersby SCOTT SHECK
BASIC Searcher finds the lines containing any command, operator, function or variable in your BASIC program. The program works on all Atari computers of any memory size. Antic Disk subscribers, follow the directions in the article.
Global search is one of the most useful editing functions found in good
word processing software. Now you can make use of the same powerful
editing tool when you're revising or debugging your own BASIC programs.
BASIC Searcher is a utility that can find all the lines containing any BASIC command, operator, function or variable in your program. It is compatible with BASIC XL (O.S.S.) and can be used with any BASIC program having line numbers below 31900.
First, type in the program listing, check it with TYPO II, and LIST it to disk using LIST "D:SEARCH.LST". Cassette owners should type LIST "C:"
HOW TO USE BASIC SEARCHER
Once the computer has a BASIC program in memory, type ENTER "D: SEARCH.LST or "ENTER C:" to merge your program with BASIC Searcher. Your program MUST be in memory before you ENTER the BASIC Searcher program!
Next, type GOTO 31900. After a brief pause, a list of your program's variables will appear on the screen. Occasionally, this list 'will include variables which no longer exist. This occurs because BASIC Searcher references your program's Variable Name Table which, in the case of a SAVED file, may have retained previously deleted variables. To clear the Variable Name Table, LIST your program to disk or cassette, type NEW, and ENTER your program again.
Each variable in the list will be accompanied by a reference number. To locate a particular variable in your program, type in its corresponding reference number and press [RETURN].
Now, type [S] to have your results printed on the screen, or [P] to have your output sent to a printer.
The program will print an "END OF SEARCH" message when it's through. If you want to perform another search, type [Y]. If not, type [N] and BASIC Searcher will erase itself from your program.
BASIC Searcher can also find BASIC reserved words, constants and character strings. just type in a reference number from the accompanying Table. If you were looking for every occurence of the POKE command, for example, you'd type in  and press [RETURN].
Although BASIC Searcher will find all references to specific variables, it cannot isolate individual constants or character strings. If you're searching for constants (reference number 14) or strings (number 15), BASIC Searcher will print out all references to every constant or string in your program.
HOW IT WORKS
BASIC Searcher looks for tokens, the one-byte codes which the Atari's BASIC interpreter uses to represent reserved words, variables and other pieces of information.
Tokens for BASIC reserved words are represented by ATASCII characters 0 through 84. The computer represents your program's variables with ATASCII characters 128 through 255. (This is why a program may not have more than 128 variables.)
As the computer interprets a BASIC program, each variable is assigned a token, beginning with ATASCII 128, and this token is appended to the Variable Name Table. At the same time, the variable's name is added to the Variable Name List, and its value is stored in the Variable Value Table. The computer uses these tables to keep track of your program's variables. BASIC Searcher looks through the Variable Name Table and the Variable Name List when analyzing your program.
Scott Sheck is one of the most creative and prolific utility programmers appearing in Antic. Last month's issue featured his "Word Storage Space Saver," an almost fiendishly clever method of reducing memory waste in text storage.