Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Very basic form problem
Message
From
18/10/2003 20:37:04
 
 
To
18/10/2003 17:44:01
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00840010
Message ID:
00840067
Views:
19
Sharon,

I have NOT read the whole thread, and I do see that you have help of top people in the field already.
I will try to amswer the questions you pose in THIS message.

It's generally a question of 'keeping' variables in scope for the required functions, not 'bring my objects into scope'

You say the the modal form you wish to display "merely displays text". *IF* that is what you REALLY mean then this would be a problem...
A form NEEDS to have some object capable of gaining/holding the FOCUS. In the case you (seem to) describe you have a form where there is no such object, and so it will start up, look for something to give focus to, find nothing and then merrily go away (because it has nothing "holding" it there because there is no input required from the user).

Now... *my* understanding of how the DO FORM command operates as far as the NAME and LINKED clauses are concerned...

From the Help:
...NAME varname...
Note that it says "varname". This means that whatever 'name' you use as "varname" is a variable name. That 'variable', in this case, can be a memvar, and array element or a property (of a form, usually). IF you have not already created a variable with the same name (using a LOCAL or PUBLIC statement with that (var)name in it or as a property of the form then the DO FORM will cause one to be created. If you omit the NAME clause altogether then VFP will create a variable named the same as the FormName (from the DO FORM FormName part of the command).

Assuming that you execute the DO FORM from a method of a form's object (say the click() of button THISFORM.ShowMe)...
IF you did not code the NAME clause at all then VFP will create a memvar to hold the name object reference and name it the same as FormName.
IF you did declare a memvar or array at the start of the method and then used that same 'name' (with element number if an array) as "varname" then VFP will store the form's object reference in the variable of that name.
In BOTH these cases the variable (name) will go OUT of scope as soon as the method that EXECUTED the DO FORM... is finished (UNLESS you declared it as PUBLIC). This is the way that VFP works as concerns scope within a function/procedure/method. However, when there is a "calling sequence" involved then any UNdeclared (or not declard LOCAL) variables created in previous functions/procedures/methods before this one in the current calling sequence and any variables named in PRIVATE statements in any of those other (prior) functions/procedures and not named (again) as PRIVATE in this method will also be IN scope.
Finally, all properties of a form are always IN scope in ALL methods and events of that form.

So your easiest route to keep the scope is to have a form property (of the calling form) and use that property name in the NAME clause, as the "varname".
Example:
-create a form property called "DisplayInfoFormObjRef" (or, more conventionally oDisplayInfoForm.
- call the form using the following:
DO FORM DisplayInfo NAME THISFORM.DisplayInfoFormObjRef...
or the more conventional:
DO FORM DisplayInfo NAME THISFORM.oDisplayInfoForm

good luck in your quest.


>OK, I've had time to digest everything and I agree I have a scoping problem. However, I am confused as to how I bring my objects into scope. I have created a simple top-level class form which contains a command button. When the command button is pressed I want the second form to appear as modal in front of the first. There will only ever be one instance of the second form running and when it is closed I want to return to the first form. The second form merely displays text. I don't know how I stop the variable from losing scope or how to attach it to another object as you suggested. Maybe you could provide an example please :)
>
>Many thanks
>
>Sharon
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform