Re: TIB: Re: (86 Basic) Please help
[Prev][Next][Index][Thread]
Re: TIB: Re: (86 Basic) Please help
First of all, I guess I have to explain a little
boolean logic. We all know that "2=3" is false and
"2=2" is true. But if you type in "2=3" on your calc
and hit enter, it says "0". This is because the calc represents
false with 0 and true with 1. Therefore, when you say "If...",
all the calc is doing is evaluating your condition, for instance
"Ans=24", and if it turns out to be 1, then it will execute commands;
if not, then it will skip commands.
:Outpt(Y,X,Q
:Lbl TOP
I figured out why up/down didn't work-- I forgot that the Ans variable
(which contains the value of the las pressed key) gets updated whenever you
store something, so when you do "...=>X", the Ans now contains the
value of X instead of the getky value. So just change the "Ans"
to "A" like so:
:Repeat A
:getKy(=>)A
:End
:If A==24 or A==25 or A==26 or A==34
:Then
:Outpt(Y,X,SP
:(A==26)(X<20) - (A==24)(X>2)+X (=>) X
Okay, here might
cause some confusion. You wanted to add 1 to X if the key pressed was 26
(right arrow) or subtract 1 from X if getky=24 (left arrow). Lets say that
getky=24 (left arrow), so A=24. Now when you evaluate (A==26), it equals
zero, and anything multiplied by zero is zero, so that whole first term won't
change the value of X. But the second term, "-(A==24)(X>2)"
will turn out as such: (A==24) is true, so it is equal to 1. (X>2) is
also true, so it will be 1. We all know 1x1=1 *I hope*. Since
there is a minus sign in front, it becomes -1. So now we have "0 - 1
+ X (=>) X". Or in other words, "X-1(=>)X". So
this line of code will subtract 1 from X if getky=24 (and X<20), add 1 to X
if getky=26 (and X>2), or do nothing to X if getky does not equal 24 or 26
(or X is on a boundary line.)
:(A==34)(Y<7) - (A==25)(Y>2)+Y (=>)
Y
:Outpt(Y,X,Q
:End
:Goto TOP
Hope this clears things up.
~Dave <the_regul8r@bigfoot.com>
Hey, I might be just dumb, but I
don't understand how this works. Can
you explain it? also, the up/down
doesn't work
:Outpt(Y,X,Q
:Lbl TOP
:Repeat
Ans
:getKy
:End
:If Ans==24 or Ans==25 or Ans==26 or
Ans==34
:Then
:Outpt(Y,X,SP
:(Ans==26)(X<20) -
(Ans==24)(X>2)+X (=>) X
:(Ans==34)(Y<7) - (Ans==25)(Y>2)+Y
(=>) Y
:Outpt(Y,X,Q
:End
:Goto TOP