★ APPLICATIONS ★ PROGRAMMATION ★ CHECKSUM MK II (CPC COMPUTING) ★ |
Checksum MK II (CPC Computing) | Applications Programmation |
Try out this re-vamped version of ROLAND WADDILOVE's life-saving debugging tool EVER since we published the Checksum utility in June 1987, we've been swamped with requests for a reprint from readers who missed it. So, in response to popular demand here it is again, but this time we have an enhanced version adapted by an enterprising reader, Arthur Smart. If you didn't see the first version of Checksum and have been pondering the significance of the Get it right! numbers, the idea is that alongside major listings we publish a list of checksums, one for each line. You can use this utility to generate checksums from the version of the program you have typed in. Lines whose checksums don't match the magazine contain one or more typing errors. To check the program from start to end, follow the instructions in the panel. The value of line must be the first line number in the program, usually 10. Pressing the spacebar will display the checksum for the lines one at a time, and the routine will end when it runs out of program. When a difference is spotted, it's a simple matter to stop the program by pressing the Escape key and edit the offending line. You can now start the routine again with CALL &9000,line, where line is the one you've just altered.
If you have typed extra spaces at the end of the line a message is displayed, and unlike the old version it's possible to tell the program to ignore it and carry on. The checksum number is then displayed and the routine continues as normal. At some stage you should remove the extra spaces and recheck the offending lines. When copying a listing make sure that everything is exactly as shown. Common mistakes are missing out the % sign on variables and typing in the wrong case, for instance M instead of m. To help avoid this, try entering the listing in lower case — abcde... instead of ABCDE.... Your CPC will automatically change them to upper case when it needs to. You must not type extra spaces within a line because, although the program may run correctly, the extra characters will give an incorrect checksum value. The reason for not running a program after it has loaded for checksumming is that its structure - and so the checksum values - is altered when you run it. This is invisible when you list it, but inside the machine changes have been made. It's perfectly all right to run a listing, save it, and reload it for checksumming, as the process is reversed when you save the program. Note that if you want to check Checksum itself, you must run it and reload it. Finally, quite a few people have been asking how the routine calculates the values. It's done using something called a cyclic redundancy check, which is bit to complicated to explain. In fact, even Roland isn't sure! Compared to doing a simple sum of the character values in the line, CRC has the advantage that it will spot characters that are correct but out of order. There is no way that a program which generates values between 0 and 65536 is going to produce an unique number for lines with up to 255 characters, because there are billions upon billions of possible lines of Basic. However, the chances of you mistyping a line in such a way that it produces the correct checksum are vanishingly small.
|