★ APPLICATIONS ★ DIVERS ★ DAVE INSTONE BREWER gives us a scanning utility for Basic programming ★ |
RSX Search (Computing With the Amstrad) | Applications Divers |
SEARCH is a utility which scans a Basic program for any specified commands or words and prints out the line numbers where they occur. It is an invaluable debugging tool for Basic programming. You could for example find all the lines which contain a GOTO command or a variable such as v$ or i% or even words which occur within a REM or within the quotation marks of a PRINT" " statement. Being written in machine code the program is very fast - but you don't have to know any machine code to use it because the utility can be called from Basic by the new command |SEARCH. Type in and save Program I. When you run it the checksum will spot any typing mistakes in the DATA lines and tell you which line to correct. If you have made no other mistakes the machine code will be automatically saved as SEARCH.BIN. Now type in Program II which is the Basic loader for the search utility. This loads SEARCH.BIN so if you are saving to tape you should save a copy of it immediately after Program II by running Program I again. If you are using discs make sure that Program II and SEARCH.BIN are on the same disc. Program II initialises the new RSX command |SEARCH by CALLing &8000. The next step is to load the program you wish to search, but to experiment with your new utility you can start by searching Program II itself. If for instance you wanted to find every line which has a REM in it you simply add a new line: 1 REMthen enter the new command |SEARCH in direct mode and the line numbers will be printed out. The program works by comparing the first line with every other line in turn. Whenever a match is found the line number is printed. There are two rules to follow when using this utility. Firstly it is generally a good idea to use capitals and lower case letters in exact copy of the line you are searching for. If you are looking for the lines containing the variable letter$ then a search for the variable LETTER$ will be fruitless. Secondly, when you are searching for words which are in quotation marks (such as in a PRINT or INPUT statement) or words which occur after a REM or DATA statement, these must be preceded by a single quotation mark in line 1. To understand why these rules are needed and how the program works, it helps to understand something about the way a Basic program is stored. Program III will allow you to see
|