Im Magazin „8000 PLUS" wurde im Juni 1990 der folgende Artikel abgedruckt1.
Ein Hilfsprogramm zur Analyse von BASIC-Programmen

BELTER.BAS by P.Whelerton


The March issue saw us sei a competition to find a program which would aid our readers when typing in listings. After an initially, shall we say, less than enthusiastic response, the programs began to come in. So, before we print Mr Whelerton's winning effort we should give honourable mentions to Jason Sharpe, Mr P Edwards, S Orr, and Max Richardson. Mr Sharpe 's entry ran an exceedingly close second and was only pipped at the post by its length — we would not be at all surprised to see it in the shops before too long, or at least in the Public Domain.
Mr Whelerton's program, although long, does include listings of GOTOs, GOSUBs and PRINT statements and can be altered to include other BASIC commands and functions. Its reports, though not as detailed as Mr Sharpe's give all the details of variables (both string, array and numeric) and commands/statements.
BELTER.BAS is 120 lines long, a little longer than wc normally like but this is a special occasion and the program was sent in before we put any restraints on the number of lines.
After you have typed it in, and debugged it, you will be asked which drive the program to be checked is to be found on. Your answer must be in the form M:, A: or B: — don't forget to include the colons. When asked to provide the filename do not include the suffix .BAS as the program assumes this. Mr Whelerton can explain the rest in his own words ...

BELTER.BAS, the March competition winner gives the 'slave' program from our Mallard BASIC article on pages 32 and 33 a good seeing to. Here the string variables are shown
"The program is designed to take BASIC programs and produce lists of the following information:
The total number of lines in the program
The total number of Numeric and String variables
The total number of REM, PRINT, GOSUB and GOTO statements.
The above are accompanied by lists of line references. Also produced are details on all numeric and string variables including:
The name of each variable
The type of each variable (array, function and so on)
The total number of references made to each variable
A list of all references by line number.
The program is fairly simple to use as most of the work is done by the computer. If the filename entered cannot be found then the program beeps (CHR$(7)) and the input will be requested again. The program will then display thai it is searching the file and will show the line number it is currently examining at the bottom of the screen. If at any point the user wishes to halt the search, simply press X (there will be a short delay before anything happens) and the program will jump straight to showing the details of variables. The output is split over three screens and requires the user to press the space bar to move on once they have read the current screen. The three tables are as follows:
1 ... The total number of variables and statements
2 ... Details of all numeric variables
3 ... Details of all string variables
Tables numbered two and three may contain more information than can fit on one screen. In this case the user will have to press a key to move onto another section of this screen."
So, there we have it. Well done to Mr Whelerton and many thanks to all the other people who sent in listings.
The initialisation of the program variables and User Defined functions are carried out here. Although most people do call the User Defined function for positioning the cursor FNat$ meaning define the cursor at .. (seen here in line 20) it can in fact be called anylhing you so wish. The beginnings of a great deal of laborious to type DATA lines are also in be found here
The DATA is held in the variable in$ - this was dimensioned earlier in line 60. The bound of this array is held in the constant, maxinsts. The DATA obviously comprises fill the BASIC built-in commands and functions. If you so wish you can erase any functions from this list which you are sure that you will never use.
The bounds for the array which hold the variable names and the line numbers of their occurences are also constants (maxi and occ). maxi denotes the maximum number of different variables which the program can deal with, occ denotes the maximum number of references to a variable that the program can log. Both can be changed but memory might become tight so watch out!
The DATA goes on and on. So, while you're typing it all in, here are the meanings of some of the program variables: bot holds the location during the binary search, tt$ holds the title of each type of word searched for,1=numeric,2=string,3=REM,4=PRINT,5=GOSUB,6=GOTO. vp is the variable name pointer which holds how many variables/functions have been found so far
Lines 500-580 request the drive and filename from you. Once the file is found (using FIND$) it is opened as a Random Access file with a record length of 1 character which is held in the variable a$. This enables one character to be read at a time.
This is the part of the program which does all the work. It works with WHILE...WEND loops, ihe outer of which runs until the End Of File is reached; this is denoted as CHR$(26). It is also curtailed by the user pressing X. Each line which is read in is also given a reference number. Another,nested,WHILE...WEND loop deals with each character as it is read in.
Line 770 removed the FN from any user defined function. It then adjusts the word length pointer (wp) and sets the class (vc=1). Line 780 adds an extra bracket to Array Type variables. When supplied with a word known to be an array it sets the class using Boolean values which set vc to show either array or integer array depending on whether the word ended in a % sign
This section uses the flag ok to show whether an end-of-word character has been found. It is almost like the routine in 780 except that the symbols $,%,and ( are allowed since they determine the type of variables. A quote ("") check is also included.
The tables with all the hard-won information are output within these lines and the small boc which follows on the nest page. Obviously you can jazz the screen display up as much as you like. As it stands, however, the program is an excellent piece of software to have in your collection, if you don't already have a programming aid you will find yourself using this more and more
That's it then, all the hard work is over and now the 'enjoyable' bit begins (no we're not getting weird over this). Debugging a program will teach you more about programming than any amount of typing in listing after listing. It will also teach you to build in specific error traps for your own work.
[BASIC-Listing]
Just to show you how we appreciate good documenlation, and the fact that we are trying to improve the general quality of the information provided in the Listings Plus pages, we have included Mr Whelerton's schematic diagram for BELTER.BAS (shown above). Making up a schematic before doing any coding is an excellent idea. It means that, in six months' time, you know one end of your magnum opus from the other. It also helps other people to understand your thought processes ... thanks again to Mr Whelerton for the incredibly detailed documentation he provided.
1. Im Heft vom April 1991 fand sich folgender Hinweis. Leider liegt mir das neue Programm nicht vor:

BELTER2.BAS

Many moons ago we published a Listing called "BELTER.BAS", a basic analysis program which provided information on any program run through it — the number of different variables used, how many times each of them appeared, where and how often all the commands were used, and so on.
However, there were some problems with it. Not least of these were the fact that it could not deal with programs of any great length.
Dr. Arthur Baker, however, wouldn't let it lie, and has been working away to improve the original. The result of his efforts is BELTER2.BAS, which ought to be able to deal with just about any Basic programof whatever size.
Unfortunately, the improvement has taken the size of the program beyond anything that could be printed in Listings. However, we are prepared — just this once, mind you — to copy it on to any blank, formatted discs that arrive at the 8000 Plus offices accompanied by an adult SAE (even better, a jiffy bag). Please mark your requests with "BELTER.BAS' on the outer envelope.

HTML-Bearbeitung von Werner Cirsovius
Februar 2015
© 8000 PLUS