Classic Computer Magazine Archive COMPUTE! ISSUE 21 / FEBRUARY 1982 / PAGE 12

Questions

I was delighted with the idea of ‘The UnwedgeTape Append and Renumber’ by David Hook in the Sept. '81 issue, p. 103, but ran into problems when I tried it out:

  1. The formula in line 26: QV$ = MID$ (STR(4 + 2*(QV = 1)),2). [What can the QV = 1 mean?]
  2. [What about the DATA statement in line 116?]..."

John Sweeney

Thanks for the kind words, John. The program was completely rechecked and, indeed, the final number in that DATA line should be H259, not H25. We make every effort to assure that typos do not get into COMPUTE!, and we feel that we have succeeded in eliminating most of the causes. However, publishing 20 to 30 programs each month results in an occasional error. We attempt to announce any corrections (or useful, optional program modifications) the following month in our CAPUTE section in the back of the magazine.

As to the meaning of QV = 1, programmers sometimes choose to use relational expressions. Try this in immediate mode: ? 5 = 5. Then try: ? 5 = 2. As you will see, if the proposed equality is true, the "value" of the equality is - 1. If false, it's zero.

10 INPUT X,Q
20 Y = Y - (X = Q)
30 ? Y: GOTO 10

Since subtracting a negative from a positive is, in fact, "addition" — the program above will increase the value of Y whenever X and Q are equal. You could achieve the same result with: 20 IF X = Q THEN Y = Y + 1. Strings can also be used as expressions and evaluated in this way. Likewise, such statements as: IF NOT X THEN PRINT "-1" or IF X THEN PRINT "0" will trigger the THEN action on -1 and zero, respectively.