Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Return Value from VCX
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00491003
Message ID:
00491066
Views:
14
I'd like to add to Hector's advice that any "Parameter" you pass to the form can be an object containing multiple default values, etc. And the return value can also be an object containing multiple values - either the same object that was passed in, or a different one. I personally don't like passing a reference to the calling form, but rather use a custom "parameters" object instead.

-Bruce Allen


>An approach that I've used is that when the user tries to close the form, I hide it instead of closing it. Then, when the control returns to the caller program I grab the values from the form (since it is still alive) and then I kill it. For example:
>
>
>procedure CallerProgram
>
>   oMyForm = createobject("frm_MyForm", lnParm1, ...)
>   oMyForm.Show() && control passes to oMyForm
>   ? oMyForm.cRetVal1, oMyForm.cRetVal2 && control returns to CallerProgram
>   oMyForm.Release()
>
>endproc
>
>
>Of course, this only works with modal forms.
>
>
>>I am looking for suggestions on returning a value from a VCX based form. As you already know, a VCX form instantiated with loMyObject = createobject("frm_MyForm", lnParm1, ...) cannot be told to capture a return value (as with SCX based DO FORM WITH ... TO ...).
>>
>>Here are some notes regarding the issue as I currently understand it. Your feedback is appreciated.
>>
>>1. One solution I see is that the Client module (the class issuing the createobject instruction) passes the Supplier form class object an object reference with a Client command method to run upon completion. Thus:
>>
>>Client Method Code says:
>>
>>local loMyObject
>>loMyObject = createobject("frm_MyForm",[THIS|THISFORM],"cmReturnMethod")
>>
>>The Supplier Form Init says:
>>
>>lparameters loClientObject, lcReturnMethod
>>THIS.cmSetClientObject(loClientObject)
>>THIS.cmSetReturnMethod(lcReturnMethod)
>>
>>...
>>
>>Later, the Supplier executes the following code as it is exiting:
>>
>>local loClientObject, lcReturnMethod, luReturnValue
>>loClientObject = THIS.qoClientObject()
>>lcReturnMethod = THIS.qcReturnMethod
>>lcReturnValue = qcReturnValue()
>>
>>evaluate("loClientObject." + lcReturnMethod + "(" + lcReturnValue + ")")
>>
>>return
>>
>>There are advantages and disadvantages to this method:
>>
>>Advantages:
>>
>>1. It provides that the Client form retains a level of genericity in that there is a generic Client Object reference with a generic return value method.
>>
>>Disadvantages:
>>
>>1. The return method MUST exist in the calling Client class object.
>>
>>2. The return method of the Client is restricted to the character or string data type of the return value without complex data type management coding in either the Client or in the Supplier.
>>
>>I know there is probably a flaw in this thinking somewhere, but I cannot see it.
>>
>>Thanks in advance for you assistance.
>>
>>Larry
"Problems cannot be solved at the same level of awareness that created them." - Albert Einstein

Bruce Allen
NTX Data
Previous
Reply
Map
View

Click here to load this message in the networking platform