|
The following article was printed in March 1988 of the magazine „8000 PLUS".
(Followed by a correction in April 1988)
|
|
Variable Lister
by Geoff Buckeridge | ![]() |
save "filename",a) and then run this listing.
Enter the name of the program to be worked on when asked, and it immediately sets to work picking out all the variables it can find and printing them on screen.
| [BASIC-Listing] |
Gremlins Corner
This month's Gremlins Corner doesn't deal so much with mistakes as with one or two suggested improvements to last month's listings.
The Variable Lister has posed a few problems because the programs you have been running through it are so complicated.
If you have more than 50 different variables in your program, the Lister will go wrong.
This is easily fixed by changing the DIM statement in line 10.
Bump the 50s in this line up to a figure greater than your greatest number of variables to solve this (for example
DIM var$(150)).
More complicated is the fact that some programs put through the lister are producing a 'String too long' error message.
This is because you've got too many occurrences of a variable (like over 50), and the variable
ln$ is getting more than 255 characters in it.
Here is a suggestion from Mr J Dulton to get round this.
Change line 390 to:390 a$=ln$(i%):newa$=newln$(i%)and then change 410 to 410 IF b%=0 THEN newa$=aS+newa$:GOTO 441Then add 441 IF newa$="" THEN 450 ELSE a%=LEN(newa$):b%=INT(a%/55)442 IF b%=0 THEN PRINT TAB(26) newa$:GOTO 450443 c%=INSTR(50,newa$,","):IF c%=0 THEN c%=a%+1444 PRINT TAB(26) LEFT$(newa$,c%-1):newa$=RIGHT$(newa$,a%-c%)445 GOTO 441Now alter 540 to 540 IF var$<>var$(j%) THEN 550and add 542 no%(j%)=no%(j%)+1546 IF LEN(ln$(j%))>240 THEN newln$(j%)=newln$(j%)+","+line$ ELSE ln$(j%)=ln$(j%)+","+line$
Other matters to clear up are the fact that of course the program only differentiates between variables and BASIC command words by the fact that it expects variables in lower case and commands in upper case.
If you have a program with variables in capitals you must convert them to lower case, which is easily done with PIP.
The command
PIP FREDL.BAS=FRED.BAS[L]creates a file FREDL.BAS which is a lower case version of FRED.BAS (you must have saved FRED.BAS with the ,A option in BASIC).
You then convert the BASIC keywords back into upper case simply by LOADing and reSAVEing the program -
BASIC automatically converts all the command words back into capitals, so the Variable Lister only picks up the variables.
The final point is something we omitted to mention.
The Lister expects the first line of your program to be a REM line which it prints at the top of the page to help you keep track of which program is being listed.
If you have any variables in this line they will be ignored.
|
| [The adapted BASIC listing] |
| 1. |
The POKE instructions used by the program restricts the usage of this tool.
The address 18527 (&H485F) refers to Mallard BASIC version 1.29.
I found the appropriate address for version 1.47 used by me, but the tool doesn't run with Microsoft BASIC.
The address refers to the statement table starting at &H47F9 for version 1.29 and &H4976 for version 1.47.
Address &H485F holds the word &H5E64, the address of the PRINT statement.
The POKE instruction changes it to amp;H5E5A, the address of the LPRINT statement.
330 IF a$="Y" THEN POKE 18527,90 ELSE POKE 18527,100 520 POKE 18527,100:ENDAt version 1.47 this is &H6047 for PRINT and &H603d for LPRINT.
In this case POKE at address &H49DC:
330 IF a$="Y" THEN POKE 18908,61 ELSE POKE 18908,71 520 POKE 18908,71:ENDA solution for this problem may be to select POKE dependent on the version — similar to FIREWORX — or select LPRINT instead of PRINT if the result should be logged.
In the early days I wrote an assembler programm to list variables in BASIC. This program only runs with Mallard BASIC, too — in addition to it the program uses the tokenized BASIC program instead of ASCII. A better choice is the program for BASIC references which I adapted for the PCW. |
HTML customization by
Werner Cirsovius
December 2014
© 8000 PLUS