ADIR()

Clear DLLs

This one is supposed to remove declared DLL functions from memory. Surprise, it works.

Usage

CLEAR DLLS [ DLLList ]
We have mixed feelings about this one. First, DLL Declares are supposed to take up a really small amount of memory, so clearing them doesn't make much sense from that standpoint. Second, if you are dealing with any objects that DECLARE the DLLs in their Inits, and then ASSuMe that these declarations will be around later to play with, blam, you just blew them out of the water. The solution, of course, is to encapsulate the declaration, use and clean up into a single method, so that you leave things as you found them.

However, VFP 7 addressed our biggest issues with this command. We can now specify which functions to clear and, more importantly, using ADLLS(), we can find out what functions are already declared. So, in the rare cases where it makes sense, we can handle these declarations intelligently.

Della points out that CLEAR DLLs makes the most sense in large applications with multiple modules. The command (together with ADLLs()) gives you a way for one module to get its hands on every bit of available memory, but still clean up after itself, so other modules don't blow up.

Example

LOCAL nDLLCount, aDLLList[1], nRow, cAlias   nDLLCount = ADLLS( aDLLList ) nRow = ASCAN( aDLLList, "DangerousFunction", -1, -1, 1, 15) IF nRow > 0    cAlias = aDLLList[ nRow, 2]    CLEAR DLLS &cAlias ENDIF
The example demonstrates two key points about CLEAR DLLS. First, it expects the alias with which the function was declared, not the name. Second, it expects the alias to be hard-coded. To use a variable, you need a macro. Name expansion (with parentheses) doesn't work here.

See Also

ADLLs(), Declare-DLL


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net