[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: Thu, 4 Dec 1997 23:39:49 -0500
Mark wrote... on Thu, 4 Dec 1997 17:17:30 -0500
>Could you specify which Technote this is--I read somewhere that you always
>had to use CALL RELEASERESOURCE on a resource handle, but this information
>may be obsolete now.

Technical Note #29    Documentation Error

GetSTRCount Function
The source code example function "GetSTRCount" on page 296 of the
FutureBASIC Reference Manual and in the "STR#" description in the
FutureBASIC online help incorrectly makes a call to the ReleaseResource
toolbox function. You should never need to call ReleaseResource from within
your FutureBASIC applications.

The function also did not check to be sure resHndl& is valid before
returning the number of strings.The corrected function follows:

 LOCAL FN GetSTRCount(resID)
   resHndl& = FN GETRESOURCE(_"STR#",resID)
   LONG IF resHndl& = 0
     resCount = -1
    resCount = {[resHndl&]}
 END FN = resCount

Mark, the FN above does not include either of the two instructions:

See my point?  I assume the resource was opened elsewhere in the program
and this small FN accesses it.  A handle was created, but, was not disposed
of before exiting the FN.