|
Im Magazin „8000 PLUS" wurde im März 1988 der folgende Artikel abgedruckt.
(Im April 1988 erfolgte eine Korrektur)
|
|
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.
|
| [Das angepasste BASIC-Listing] |
| 1. |
Die im Text erwähnten POKE-Anweisungen schränken den Gebrauch des Programmes ein.
Es handelt sich hier um eine Adresse der Mallard BASIC Version 1.29.
Zwar habe ich die entsprechende Adresse für die von mir genutzen Version 1.47 gefunden, allerdings ist das Programm mit dem Microsoft BASIC nicht lauffähig.
Die Adresse bezieht sich auf die Statement-Tabelle, die bei Version 1.29 bei &H47F9 und bei bei Version 1.47 bei &H4976 beginnt.
In der Adresse &H485F steht die Adresse &H5E64, das ist die Adresse der PRINT-Anweisung.
Durch die POKE-Anweisung wird die Adresse geändert auf &H5E5A, das ist die Adresse der LPRINT-Anweisung.
330 IF a$="Y" THEN POKE 18527,90 ELSE POKE 18527,100 520 POKE 18527,100:ENDBei der Version 1.47 ist &H6047 die Adresse der PRINT-Anweisung und &H603d die Adresse der LPRINT-Anweisung.
In dieser Version muss dann die POKE-Anweisung für Adresse &H49DC ausgeführt werden.
330 IF a$="Y" THEN POKE 18908,61 ELSE POKE 18908,71 520 POKE 18908,71:ENDDie Lösung zu dem Problem wäre: Abfrage der Version und dann entsprechende unterschiedliche-Anweisungen — ähnlich wie in FIREWORX — oder Änderung der PRINT- in die LPRINT-Anweisung an den entsprechenden Stellen, wenn das Ergebnis auf dem Drucker protokolliert werden soll.
Ich hatte ein Programm zum Listen von Variablen in Assembler geschrieben. Auch dieses Programm läuft nur mit Variablen unter Mallard BASIC — darüberhinaus läft es nur mit BASIC Tokens anstatt mit ASCII Zeichen. Besser ist da das BASIC-Programm für BASIC Referenzen, das ich für den PCW angepasst habe. |
HTML-Bearbeitung von
Werner Cirsovius
Dezember 2014
© 8000 PLUS