[futurebasic] Re: [FB] Locking handles (was:Re: [FB] Strings > 255 chara

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

From: Chris.Young@...
Date: Thu, 29 Oct 1998 09:15:49 -0600
Hans wrote:

< But would the following ever crash?

< DIM array%(1)
< resH& = FN GET1RESOURCE(_"DATA",128)
< LONG IF resH% AND FN RESERROR = _noErr
<     BLOCKMOVE [resH&], @array%(0), 4
< END IF

The only thing I can see is changing the LONG IF to:

LONG IF (resH& <> 0) AND FN RESERROR = _noErr
(also note the typo resH%in your code)

FB does a bitwise AND operation--therefore, when ANDing conditions, always turn 
each condition into a true/false test in order to ensure that you get the result
you are expecting. To illustrate this, consider ANDing two variables, a AND b, 
where a = 3 (0000 0011) and b = 4 (0000 0100). You would logically expect that a
AND b would return true if a AND b are nonzero. Because of the bitwise ANDing, 
however, you would get 0:

0000 0011
0000 0100
---------
0000 0000

As far as your handle goes, since you are dereferencing ([resH&]) each time thru
the loop, you would be OK.

Chris Young