PRB: Form Variable Unknown After Running Form Inside AppID: Q131752 3.00 WINDOWS kbprg kbprb The information in this article applies to:
SYMPTOMSIf you create a form and then run that form from the Command window, the variable that contains the instance of the form object is, in fact, in memory. If the function TYPE('myform') is placed in the Debug window, the value "O" for object is displayed. When running the same form in an application, however, the variable is not shown when memory is displayed and the function TYPE('myform') returns "U" for undefined.
CAUSEWhen you use the DO FORM command, you create both an instance variable and a form object. When you use the DO FORM command from the Command window, the instance variable is by default public. That's why you always see it. When you use the DO FORM command in a program, the instance variable is private by default. When control returns to the program to the line following the DO FORM command, the variable is out of scope and the TYPE function returns "U."
WORKAROUNDSet the WindowType property of the form to modal to keep the object in scope, or create a public variable, as in this example:
Make the program (the .PRG file) the main file in the project, and rebuild
the application.
STATUSThis behavior is by design.
MORE INFORMATIONWhile the scope of the variable created within the application is limited to the application, the variable created when the form is run from the Command window is global within the Visual FoxPro development environment.
Steps to Reproduce Behavior1. Create a form using the Form Designer. 2. Place the TYPE('myform') function in the Debug window. 3. Run the form. The Debug window shows "O." 4. Display memory, and verify that <myform> is listed as a variable. 5. Add the form to a project. 6. Build an application. 7. Use the CLEAR ALL command to clear memory. 8. Run the application. The Debug window displays "U." Display memory and Additional reference words: 3.00 VFoxWin
KBCategory: kbprg kbprb
KBSubcategory: FxprgClassoop
|
Last Reviewed: May 1, 1996 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |