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

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

From: wave@... (M Goodes)
Date: Sat, 6 Dec 1997 22:18:34 -0500
Just want to make sure that you are totally clear on something that Rick
pointed out in an earlier post.  See below.

>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

Your comment beside the satement above may or may not be correct depending
on what you mean by "create a temp handle".  Here you are not creating the
memory block itself; FB did this when you created the EDIT FIELD.  Instead,
you are making a copy of a value which points to the block (actually, which
points to the master pointer which points to the block).  If you were, at
this point to write "efHndl&=0", then it would not affect the memory block
at all.  Of course, this fact is irrelevant to your current code--but it's
good to be aware of it anyway.

Sorry if this wasn't necessary--just wanted to make sure, since this is
very difficult to learn the first time.

>  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

Use e-mail with integrity.
Mark Goodes (wave@...)