PRB: Form Variable Unknown After Running Form Inside AppLast reviewed: April 30, 1996Article ID: Q131752 |
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:
PUBLIC myform DO FORM myformMake 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 Behavior
|
Additional reference words: 3.00 VFoxWin
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |