>>>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...