[futurebasic] Re: When to dispose of Hndl& and Ptr&?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 1997 : Group Archive : Group : All Groups

From: Bill Kuck <bypass91@...>
Date: Fri, 5 Dec 1997 23:25:38 -0500
Thank you for the generous replies on what is a difficult concept for me.
From what I have read in your responses, the answer to this question for me
anyway, is really "when to dispose of the block of memory" that the pointer
and/or handle were pointing to.  I have been so concerned about handles and
pointers, that I lost concept of what's really the important issue, the
memory block.

I'd like to offer this little example to see if I understand what everyone
said.  Please correct me as I go because I think I've almost got it.. just
a little nudge or two might do it for me.

1) Create an edit field
2) Call FN that does something with edit field,
   but, do not dispose of the edit field in the FN
3) Dispose of the edit field

LOCAL FN doSomething(efID%)
  efHndl& = TEHANDLE(efID%)   'create a temp handle to ef
  efFont% = efHndl&..teFont%  'get the font, we're done
' Notes about exiting FN:
' handle efHndl& lost, but ok, edit field still intack
' if DEF DISPOSEH(efHndl&) were used in the above, we
' would have lost the edit field, right?

WINDOW 1                      'create window
TEXT _monaco,9
EDIT FIELD 1,"",(5,5)-(20,20) 'create edit field
FN doSomething(1)             'get font
WINDOW CLOSE 1                'close window, edit field