Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do you return data from a modal Form object?
Message
From
23/03/1998 05:27:23
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00085149
Message ID:
00086327
Views:
39
>>I have been trying unsuccessfully to get a return value from a form created with createobject(""). An example of what I am trying to do: display a form and allow the user to select or enter a value from then return the value selected. This is a no brainer with a standard form but I have been trying it with a form object created from a class library and cannot figure how to get the value back to the calling program.
>>
>>Is there a way to designate a return variable like " DO FORM x WITH varx TO varz? I have tried passing variable by reference. I have tried modeless forms and can't seem to get control back to the calling program. If I use properties in a modal form the property is destroyed prior to returning to the calling program. I have finally sunk to creating a global variable prior to creating the form and releasing it immediately after.
>>
>>I know there must be a better way.
>
>Whoa! Don't do Public! Try this:
>
>To return a value from a form
>
>1. Set the WindowType property of the form to 1 to make the form modal.
>2. In the code associated with the UnLoad event of the form, include a RETURN command with the return value.
>3. In the program or method that runs the form, include the TO keyword in the DO FORM command.
>
>For example, if FindCustID is a modal form that returns a character value, the following line of code stores the return value to a variable named cCustID.
>
>DO FORM FindCustID TO cCustID
>
>This was in VFP3 help but I couldn't find it in VFP5 help. ("help returning" at the command window.)
>
>I've used it several times & it works like a charm.
>
>JR
Hi Joy,
Of course we all do use it with modal forms where applicable. But think of this, what would you do if you need four return values ? Or would the return parameters would change based on the intermediate results of caller ? Modal forms wouldn't let you change something on caller form and would nearly be impossible to implement with ease in SDI forms. So think of this approach too :
do form myModeless with myVar, thisform  && Pass also form reference
*myModeless.init
lparameters cVar, oCallerRef
thisform.oCaller = oCallerRef   && A custom form property

* Any PEM
thisform.oCaller.anyPEM     && Now you can directly change 
                            && or call any PEM of caller form
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform