Classic Computer Magazine Archive COMPUTE! ISSUE 76 / SEPTEMBER 1986 / PAGE 10

Reader's Feedback

The Editors and Readers of COMPUTE!

If you have any questions, comments, or suggestions you would like to see addressed in this column, write to "Readers' Feedback," COMPUTE!, P.O. Box 5406, Greensboro, NC 27403. Due to the volume of mail we receive, we regret that we cannot provide personal answers to technical questions.


Spaced Out Operators

I enjoyed Bill Boegelein's "Amiga Puzzle" article in the May 1986 issue of COMPUTE!. I did have one problem, however, that may be of interest to your readers. The mistake was mine, not yours or the author's, but the solution might help everyone type in programs more accurately. The Play subroutine of Amiga Puzzle contains a complex IF statement that begins like this:

IF (mouseX>rat(x,y,O) AND ...

I mistakenly entered that portion of the statement like this:

IF (mouseX.rat(x,y,0) AND  ,

Notice my inadvertent use of a period in place of the greater-than operator (>). Clearly, I forgot to hold down the SHIFT key when typing the > character. The problem arises because Amiga BASIC lets you include a period as part of a variable name. Instead of performing the logical comparison triggered by >, BASIC saw mouseX.rat as the name of an array. Of course, there is no such array or variable in the program, so its value was set to zero, like all other uninitialized variables. As a result, this part of the IF test is always false and the program's CheckCheat routine can never be called.

Although I was lucky enough to find this error without much searching, similar mistakes could be very difficult to detect in other situations. As a precautionary measure, I suggest that programmers always place a blank space on either side of a logical operator, as shown here:

IF (mouseX > rat(x,y,0) AND 

If the original line had been written in this way, my typing error would have been much easier to spot. More to the point, BASIC itself would have detected the mistake and signaled a syntax error immediately. Again, the problem was mine, not Mr. Boegelein's or yours. But it could easily be prevented by following this simple rule.

Jack Purdum

Thanks for the suggestion.