[futurebasic] Re: [FB] [FB^3] DEF DISPOSEH question

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2000 : Group Archive : Group : All Groups

From: jonathan <jonnnathan@...>
Date: Thu, 30 Nov 2000 09:30:43 +0100
le 2000/11/30 9:15, Heather Donahue à HeatherDonahue@... a écrit :

> What I don't understand is the use of "vPtr&.nil&".  Is .nil& the
> same as the constant _nil?
> 
> My guess is that it is dereferencing the handle to get to the master
> pointer.  If it is not zero it uses HGETSTATE to get the properties
> of the block of memory.  HGETSTATE wants a handle, so aren't we
> giving it a pointer?
> 
> Next, the variable state& and 0x0020 checks bit 5 of the result to
> see if it is a resource.  We don't check to see if the block is
> locked, is it ok to dispose of a locked block?
> 
> Finally the line 'vPtr&.nil& = 0', does this set the master pointer to zero?

Heather

you explanation seems a fair description of how this works! except...
it takes the address of the handle (which points to the master pointer). it
uses this to get the state, and thus determine that it is not a resource
handle. 

.nil& and _nil are different syntax for the same thing.

by zeroing the handle it is then possible later to include a test:

long if( handle)
  do something
xelse
  handle no longer valid
end if

if you do try to reuse the handle, thinking that it is valid, you will get
an address zero error. sometimes i put &DEADBEEF into handles that are no
longer in use, this is a distinctive signature that then tells me
explicitely what i have done, whereas an address zero error can be caused by
others of my programming mmistakes!

hth
:-j
(resident list gnome - honorific)