★ APPLICATIONS ★ DIVERS ★ CHEXSUM ★ |
Chexsum | Applications Divers |
The unique CHEXSUM program validation WHY When a book of programs such as this book is keyed in, everybody invariably makes reading and typing mistakes and then spends ages trying to sort out where and what is causing the error (errors). Even experienced programmers often cannot identify an error just by listing the relevant line and need to do the tedious job of going back to the book, especially with DATA statements. Realising that this is a major cause of frustration in keying the programs, we decided to do something about it. There is a short routine in this book which you should key in and save BEFORE you key in other programs. Using this routine you will be able to find out if you have made any keying errors at all and in which lines, before you even run the program. In effect this means that with this book you need not waste time looking for keying errors, you simply run the routines and look at the display to identify lines containing errors. It's that easy. The principle behind the routines is a unique chexsum which is calculated on each individual line of the program as you have keyed it in. Compare this chexsum value with the value for that line in the list at the end of the program listing; if they are the same the line is correct, if not there is an error in that line. WHEN The simplest method is to enter the CHEXSUM program in now and save it to tape or disk. You can type in the chexsum program at any time, even if you have started to type in a program. You cannot, of course LOAD in CHEXSUM from tape or disk because it will erase all you have typed so far. The obvious solution is to MERGE the programs. The CHEXSUM program should be saved onto a separate cassette to allow easy access. HOW CAN YOU TELL IF CHEXSUM HAS BEEN ENTERED CORRECTLY? After having keyed CHEXSUM the logical thing would be to chexsum the program to make sure it is correct. But is it possible to do this? If you follow the instructions you will be able to check CHEXSUM.
Below is the listing of CHEXSUM and instructions on its use. USING CHEXSUM ChexSum is a special program which generates a unique sum for each line in a program and a grand total of all line sums. After each program listing is a table of check sums. You need only compare the numbers in the ChexSum table for each program with those generated by ChexSum. If two numbers differ, check that particular line. 1. Type in your game program, Patterns, say. Save it to tape or disk with the statement; SAVE “PATTERNS". 2. Reload your game program if necessary, using the statement; LOAD “PATTERNS" for the first game in the book. Do not RUN the game at this point. 3. To join ChexSum to the end of your program, enter the statement; MERGE "CHEXSUM". 4. When merged, enter RUN 60000 to activate ChexSum. The program will prompt: OUTPUT TO PRINTER (P) OR SCREEN (S) Enter a P will cause output to go to the printer, and entering S will cause output to go to the screen. 5. ChexSum next prompts: STARTING LINE NUMBER Enter the first line number in the program to be checked and press ENTER. 6. ChexSum will now output the check-sum table for the program. To halt the program press the escape key once, and to restart the output press any key other than escape. When ChexSum has finished you may remove ChexSum from memory with the DELETE instruction. For example: DELETE 60000 — 62990 7. Check your grand total with that in the book. If they differ a line has been entered incorrectly. Compare line numbers until you locate the bad ones and then edit them. 8. Repeat steps 4 to 7 until the games program is debugged. In step 5 enter the line number of the first bad line to avoid ChexSum verifying the games program from the first line. 9. When the games program is running satisfactorily, delete the ChexSum program as described above. 10. Finally save the debugged version onto a clean tape or disk, with:
|