ROM Computer Magazine Archive ROM MAGAZINE ISSUE 6 — JUNE/JULY 1984 / PAGE 27

by Bob Cockroft

    Are you tired of spending much time copying in ROM programs, only to discover that you have made a number of typing errors? Well, your problems are over! PROGRAM CHECKER is a utility that will locate your errors.
    The program's mechanics are simple. First, type-in and SAVE the PROGRAM CHECKER. Second, create an untokenized file of the program you want to check. This is done by LISTing the filename to the disk.


    Make certain that the program to be corrected has no gross errors such as missing lines. Now, LOAD and RUN the PROGRAM CHECKER. A new screen will immediately appear. It will ask for the filename of the program you want to check. Type-in the desired disk number and filename.


    Soon after pressing the RETURN key the screen will go blank and the disk drive will be turned-on. The PROGRAM CHECKER is now examining your program. Each line is given an identification number. These numbers are stored in an array so that they can later be displayed. The longer your program is, the longer this process will take.
    After several seconds a new screen will appear. It will ask you which technique you wish to use to display the DATA output. Three options are given: the Screen(S), the Printer(P) or the Program(R). The first option, the screen, is best for short programs. This technique uses the screen to display the DATA. Unfortunately, longer programs may have more data statements that can be displayed on the screen at one time. This makes the Screen option useless for larger programs. The second option, the Printer(P), can be used for all programs. Unfortunately, this technique tends to waste paper and obviously would be unsuitable for those who do not have printers. This leaves us with the third and last option. The Program(P) option creates an untokenized file that contains the data statements. This technique can be used for any program. After pressing `R' the disk drive will be turned-on. In a few seconds, after the Program Data has been created, the READY prompt will appear. Erase the PROGRAM CHECKER, and ENTER and LIST the DATA program. In order to do this, type the following:


    If you have done everything correctly, a series of data statements will appear on the screen.
    Beginning with the sixth issue most programs in ROM will contain a separate group of data statements. These statements are called CHECK DATA. They represent the identification code for the program as it would be if it were correctly typed-in. Below is an example of this:


10 DATA 4259,57,484,44,347,34,3,567,44,33,4,55,334,6,356,245,753,547,346
170 DATA 4549,45,5,8,456,56,3,6,655,346,445,446,443,678,446,44,7,456,4
330 DATA 1011,556,355,34,66

    You may have noticed that the first unit of data in each line is larger than the rest. The reason is that this value represents the summation of all the values in the line. The rest of the data numbers represent individual lines of the program you are checking. To aid identification, the data displays the lines in numerical order. This means that the second data number in each line represents the program line that corresponds to the data line. For example, the `57' in DATA line 10, represents line 10 in your program, whereas the neighoring `484' represents the first line that follows line 10 in your program. (Perhaps line 20) The `44' represents the second line that follows program line 10.(Perhaps line 30) In this way, any line in a program can be identified by its data position.
    No matter which one of the three output options one chooses(Screen,Printer or Program), the PROGRAM CHECKER will produce a series of Data statements similar to, if not the same as the ones in the corresponding CHECK DATA. The Program Data below is the identification code that is produced by the PROGRAM CHECKER for the program you typed-in. Any errors in typing would be contained in this data. The CHECK DATA is really the Program Data as it would be without any errors. Therefore, by comparing the potentially error filled Program Data with correct CHECK DATA, any errors would be made visible. If the Program Data differs in any way from the ideal CHECK DATA, your program contains an error.

Program Data

10 DATA 4259,57,484,44,347,34,3,567,44,33,4,55,334,6,356,245,753,547,346
170 DATA 4545,45,5,4,456,56,3,6,655,346,445,446,443,678,446,44,7,456,4
330 DATA 1011,556,355,34,66

    Compare the first unit of data in each line of the CHECK DATA with its corresponding value in the Program Data. If the values are the same, every program line that is represented in that data line is correct. If the two values are different, one or more lines in your program are incorrect. For example, examine line 170 in both the CHECK and the Program Data. Because the summation numbers in the CHECK DATA and Program data do not correspond, an error exists. Further examination will reveal that the fourth data numbers do not correspond with each other. Because the Program data does not match with the CHECK DATA, an error exists. In order to determine the program line that contains the error, the first data number, the summation(4545), must be disregarded. The next value `45' represents the program line 170, the value that corresponds to the data line. The following value `5' represents the line in your program that comes after line 170. This could be line 180 or any other line that immediately follows line 170. Finally, the next value is the one that contains the error. Because the error lies two numbers past the value that represents line 170, the program line that contains the error lies two lines after 170. ReLOAD the program you have been checking, and correct this line. Continue examining the remaining numbers in both the CHECK and Program Data for further errors.
    Once you have learned how to use the program checker, it will become quick and easy to use. Although other magazines have programs to check for errors, ROM CHECK DATA is compatible to the PROGRAM CHECKER only.

112 ? :? "    PROGRAM CHECKER":?
115 ? "    The screen will go blank after        entering the FILENAME":? :?
120 DIM PR$(14)
140 P559=PEEK(559)
145 POKE 559,0
150 LINE=0:G=0:N=0
160 TRAP 130:OPEN #1,4,0,PR$
170 DIM K$(5),A$(126)
180 TRAP 200:INPUT #1,A$:LT=LT+1
190 GOTO 180
200 CLOSE #1:Q=INT(LT/17):DIM C(LT),R(Q),SP$(15)
210 OPEN #1,4,0,PR$:GOTO 220
220 FOR J=1 TO 5:K$(J)=" ":NEXT J
230 N=0
240 INPUT #1;A$:N=N+1:U=1
250 IF A$(U,U)<>" " THEN K$(U)=A$(U):U=U+1:GOTO 250
260 LINE=VAL(K$)
270 R(G)=LINE:G=G+1
280 TRAP 310:INPUT #1;A$
290 N=N+1:IF N=17 THEN N=0:GOTO 240
300 GOTO 280
310 CLOSE #1:OPEN #1,4,0,PR$
320 FOR I=1 TO LT:SM=0
330 GET #1,WT:SM=SM+WT
340 IF WT=155 THEN 360
350 GOTO 330
360 SM=SM-1000*INT(SM/1000)
370 C(I)=SM:X=2
380 NEXT I
390 CLOSE #1:M=0:LINE=R(0)
405 POKE 559,P559
410 ? :? "Screen(S) or Printer(P) or Program(R) output?":INPUT SP$:? :?
420 IF SP$="R" THEN OPEN #1,8,0,"D:D"
430 TRAP 410
440 ST=0:N=17
450 IF LT<17 THEN N=LT
460 IF SP$="P" THEN 510
470 IF SP$="R" THEN 540
485 FOR Y=1 TO N:ST=ST+C(17*M+Y):NEXT Y
486 PRINT ST;",";
490 FOR Y=1 TO N:PRINT C(17*M+Y);:IF Y=N THEN ? " ":GOTO 494
492 ? ",";
494 NEXT Y:GOTO 570
515 FOR Y=1 TO N:ST=ST+C(17*M+Y):NEXT Y
517 LPRINT ST;",";
524 NEXT Y:GOTO 570
540 PRINT #1;LINE;" DATA ";
545 FOR Y=1 TO N:ST=ST+C(17*M+Y):NEXT Y
547 PRINT #1,ST;",";
552 PRINT #1;DAT;",";
554 NEXT Y
570 LT=LT-17:M=M+1
580 IF LT<l THEN 610
590 LINE=R(M)
600 GOTO 440
610 END