PRB: Form Variable Unknown After Running Form Inside App (131752)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 3.0
This article was previously published under Q131752 SYMPTOMS
If 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.
CAUSE
When 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."
WORKAROUND
Set 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 myform
Make the program (the .PRG file) the main file in the project, and rebuild
the application.
STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 2/15/2000 |
---|
Keywords: | KB131752 |
---|
|