Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do you return data from a modal Form object?
Message
From
18/03/1998 16:35:36
 
 
To
17/03/1998 15:47:57
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00085149
Message ID:
00085479
Views:
42
>>>The simplistic way is following:
>>>PUBLIC gVar1 && it's better to use oApp property here
>>>gVar1=""
>>>createobject(...) && and reset gVar1 in e.g. Newform.Destroy event

>>IOW, PUBLIC is a dirty word and should not be typed in any program. The requirement for "global" variables can be met by creating the variable in the startup program (the one with teh read events).

>Yes, I used 'public' just to give quick(dirty) idea, and wrote comments that it's 'simplistic' way and oApp property should be used.

(humor flag up)

Ed, you've been sufficiently thwacked for that PUBLIC variable suggestion, so I won't add insult to injury...much.... ;)

(humor flag down)

Remember that I only instantiate forms from class libraries. So, if I need to pass return values from a dialog, I consider the dialog the "carrier" of those values and implement it by making the return values properties of a class which happens to be a Form. I instantiate the class, preset properties if needed (such as an old value that we are updating), then show the Form. Once the work in the dialog has been done, I "close" the dialog by executing Hide(), then extracting the return values from the From in the calling code. At that point, the form can be released. The code from the calling program might look something like this:
LOCAL loDialogForm, lcName

loDialogForm = CreateObject("MyModalDialog")
WITH loDialogForm
    .txtName.Value = "This is my default name"
    .lSuccess = .F.
    .Show()

    IF .lSuccess
        lcName = .txtName.Value
    ENDIF
    .Release()
ENDWITH
...or something like that...
David M. Stowell
Ravenslake Consulting
Chicago, Illinois

e-mail: davidstowell@ravenslakeconsulting.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform