DOCUMENT:Q129281 25-AUG-1999 [foxpro] TITLE :How to Implement a RELEASE Method PRODUCT :Microsoft FoxPro PROD/VER:3.00 OPER/SYS: KEYWORDS:kbcode ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual FoxPro for Windows, version 3.0 ------------------------------------------------------------------------------- SUMMARY ======= This article describes how to implement a RELEASE method in classes that do not include a default RELEASE method. MORE INFORMATION ================ When an object is instantiated, a variable, called an instance variable, is created. Executing a form with a DO FORM command creates a Form object and an instance variable. If the LINKED clause is included with the DO FORM command, the form is associated with the instance variable, and releasing the instance variable will also release the form. By default, the LINKED clause is not included with the DO FORM. If the form is not linked, you can release the variable while the form is active. The RELEASE method is therefore necessary to the FORM or FORMSET classes to release forms that do not have an associated instance variable. Any object based on a class other than Form or FormSet is released when the instance variable goes out of scope or is released. You can however implement a custom RELEASE method that includes this command: RELEASE this && This command releases the current object Sample Code ----------- The following example code defines a toolbar that contains two command buttons. One of the command buttons is a QUIT button. When the button is clicked, the RELEASE method is called and the toolbar is released. Note that in this example, the THISFORM keyword is used to generically reference the toolbar. PUBLIC oToolbar oToolbar=CREATEOBJECT('mytoolbar') oToolbar.show DEFINE CLASS mytoolbar AS TOOLBAR ADD OBJECT mycmd AS cmdmessage ADD OBJECT mycmdtwo AS cmdquit PROCEDURE RELEASE RELEASE THIS ENDPROC ENDDEFINE DEFINE CLASS cmdmessage AS COMMANDBUTTON Height=35 Width=35 Caption="Clients" PROCEDURE CLICK =MESSAGEBOX('To be implemented') ENDPROC ENDDEFINE *: *: Class: mycmdquit BaseClass: COMMANDBUTTON *: DEFINE CLASS cmdquit AS COMMANDBUTTON Height=35 Width=35 CAPTION="Quit" PROCEDURE CLICK THISFORM.RELEASE ENDPROC ENDDEFINE Additional query words: VFoxWin ====================================================================== Keywords : kbcode Technology : kbVFPsearch kbAudDeveloper kbVFP300 Version : 3.00 ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 1999.