stevepoole wrote:Hi,
A simple way to avoid name-table clashes is to type EXTRAS to get a list of names, before loading any suspect code...
So having a printed listing of the suspect code is handy !
This is of course a manual process, not an automatic one, but usually makes things clear... Anyone fancy writing a name checker ?
One of my favourite pitfalls in trigonometry is using : ax, bx, cx, dx , ex ....
Steve.
Here is a little "proof of concept" I've quickly knocked together this morning for a "Name Check" program. Further work needed of course, this is a simple demo.
This is a short BASIC program which takes the alphabetically sorted names list in the text file "namessc_txt" in the zip file attached, and asks you to enter a variable name. It scans through the plain text file looking for the name. The text file, which can be edited in any plain text editor to add or amend names, has three columns, separated by semi-colons:
NAME;TYPE;IN_WHICH_TOOLKITS
The name would be any standard keyword name.
The type is a single character - such as F for function, P for procedure, - for unknown type etc etc
IN_WHICH_TOOLKIT is just a short line of text listing which toolkit(s) the keyword is found in.
This list is taken from a file on Wolfgang Lenerz's website (also on my site, but not sure which is more recent) at
http://www.wlenerz.com/smsqe/addkeys.html
My program is a simple binary chop search routine (hence why the text file has to be sorted in alphabetical order). At the moment, all the program does is ask you to input a name, and searches through the list looking for matches and prints them to the screen. Needs to be run in BASIC at the moment with windows set to TV mode (unless you add some WINDOW commands at the beginning).
If you wish to tinker with it while I work on it, the important line is line 570, which does the searching by calling the procedure SEARCH_FOR with the name you entered in line 550. That procedure does the binary search and formats the output list of name matches. Most of the code in the earlier part of the program is just to do with loading and preparing the names text list into an array called array$. Not much error trapping and the binary search could probably be made more efficient as it was simply lifted from an existing routine in an older program of mine.
I hope to add two more options to it:
1. QREF software users could create a list of names used in their programs with QREF_V and QREF_P sent to a file (OPEN_NEW#3,ram1_VARS_TXT:QREF_V#3:CLOSE#3) and process this to extract the variable/procedure names - the format of file produced by QREF makes it fairly easy to process the list I think). This could automate the checking of names.
2. I hope to extract a routine from my Basic Reporter program which scans the name table to extract a list of names in your loaded BASIC program. This uses commands in Turbo Toolkit, so if compiled would work alongside BASIC (like Basic Reporter) to do an automated check of names in your currently loaded BASIC program on request.
Will see what I can come up with this afternoon. Meantime, feel free to tinker!
namecheck.jpg
namecheck.zip
EDIT: I forgot to mention that the program loads the text file from ram1_ for speed, change this in line 170 as required.