HP "calculators" (was Re: World's first computer on ebay!)
M H Stein
dm561 at torfree.net
Sat Apr 14 13:37:47 CDT 2007
Date: Sat, 14 Apr 2007 07:51:58 -0700
From: "Chuck Guzis" <cclist at sydex.com>
Subject: Re: HP "calculators" (was Re: World's first computer on
I said "X=Y=7" in GWBASIC changes both X and Y the same way
regardless of their initial values. LET X=Y=7 changes them a
different way, regardless of their initial values. If there's a
conditional operator in either of those statements, I can't find it.
Yes, it's true that BASIC doesn't differentiate lexically between the
assignment operator and equality test, but that seems to be unrelated
to the behavior of the two statements I gave. In fact, I don't know
what the operation performed by GWBASIC is in "X=Y=7".
We can't be talking about the same thing here; I program a fair
bit in BASIC and use this technique quite often; (Y=7) is equivalent
to 0 or -1 (0000H or FFFFH, depending on Y, when it is in a place
where a numeric variable is expected. So if I read your examples
correctly, when Y is 7 then (Y=7) is -1; in essence TRUE has a
value of -1 and FALSE has a value of 0.
The conditional operator is implied, which is why it's useful when
an explicit IF/THEN is awkward; If Y=7 then (Y=7) is -1 else (Y=7) is 0.
Y never changes.
Just try: Y=7:PRINT Y=7: Y=6: PRINT Y=7
or: Y=7:PRINT Y>6:Y=6:PRINT Y>6
or: A$="X":PRINT A$="X":A$="Y":PRINT A$="X"
or, to make it even more obscure:
INPUT "Guess a letter":A$:PRINT mid$("WRONGRIGHT",-(A$="Z")*5+1,5)
Admittedly, it's counterintuitive; X=Y=7 sure looks like a multiple assignment.
More information about the cctalk