[futurebasic] Re: [FB] Embeded LONG IFs

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 1999 : Group Archive : Group : All Groups

From: Jay Reeve <jktr@...>
Date: Tue, 19 Oct 99 14:19:18 -0500
Paul,

I agree. Let me just add a note or two.

>I'll beat the horse some more. Yes, you can use parentheses if you want
>to, but they are by no means necessary as long as you stay away from the
>"implied" stuff like this:
>
>LONG IF myVar%                               'This would be OK
>
>LONG IF myVar% = 4                           'This would be OK
>
>LONG IF myVar% = 4 and myOtherVar% = 5       'Even this is OK
>
>LONG IF myVar% and myOtherVar% = 5           'Here is the bad stuff!!!
>
>This results in trouble unless you are super familiar with how the
>compiler "thinks" of this code.
>
>Does it see: LONG IF (myVar% and myOtherVar%) = 5
No.
>
>Or does it see LONG IF (myVar%) and (myOtherVar% = 5) ??
Yes. There is a hierarchy, and comparisons take place before AND. So this 
example works as well as the others, and is what I often use. The one to 
avoid is:
  LONG IF myVar% and myOtherVar%
Unless you're checking to make sure their values have at least one bit in 
common.
>
>I just write it as  LONG IF myVar% = 4 AND myOtherVar% = 5
>
As an added note, when doing series of ifs, I (generally) avoid ANDs, 
because each element of the AND statement must be evaluated and the 
results all ANDed before any decision will be made. I find it both more 
efficient and clearer to just use the long series.

 0"0
 =J= a  y
  "