-------------Original Message
Date: Sat, 14 Apr 2007 13:29:52 -0700
From: "Chuck Guzis" <cclist at sydex.com>
Subject: Re: HP "calculators" (was Re: World's first computer on
ebay!)
On 14 Apr 2007 at 15:59, M H Stein wrote:
Maybe what's missing in my blathering is that when
BASIC does a
conditional test it's actually looking for a non-zero number in whatever
its argument is, which could be a logical expression (which returns 0 or -1)
or simply a variable.
So instead of IF A <> 0 THEN... you can just say IF A THEN...,
something you'll see throughout my sloppy code ;-).
I tried it again this afternoon and it works as you said. But last
night, I tried it over and over again in my GWBASIC and got the
results that I mentioned. No mistake--I'm certain of it--I had to
repeat it about 5 times to make sure that I wasn't imagining things.
Either that or I need to have my ginger ale tested for hallucinogens.
It DOES point out the obvious need for LET in some cases. LET X=Y=7
is different from X=Y=7.
Cheers,
Chuck
--------------Reply:
Well, Chuck, as one old geezer to another, either one of us needs
to be tested for Alzheimer's, you are indeed drinking or smoking
some funny stuff, or you're using some obscure beta version of
GWBASIC from the old days. AFAIK there is no difference whatsoever
whether you use LET or not; what do you get that makes you
believe otherwise? Perhaps there IS some particular set of
circumstances where what you say happens, but I doubt that
Bill would be interested in fixing it at this point in time...
-------
Tony:
I beleive there was at least one BASIC where you could
write A=B=0 (and
it meant assinge 0 to A and to B, not set A to the boolean value of the
compariston between B and 0, which it meant in some other BASICs)
We were talking about GWBASIC, but you're probably quite right, and thank
you for putting it more succinctly than my convoluted explanation.
A lot of BASICs would take a line like IF X=0 THEN
Y=SIN(D):Z=D*D+2
and do both assingments iff X equalled 0
GWBASIC included; in fact, it's because of the way IF/THEN works that
the technique of avoiding it by using a boolean as a numeric variable is so
useful at times.
--------
Fred:
So, apparently it is parsing it as x = (Y==7);
Exactly; thank you too for a much clearer explanation than mine.
An alternative to LET is to have different symbols for
assignment v
comparison. == , .EQ. etc
I always liked the APL X <- 3,
which also avoids the beginner mistake of 3 = x
Makes much more sense to me too, but let's not get into one of those
BASIC-bashing language comparion threads; it's too easy a target... ;)
m