Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Returning 2 values from a form
Message
From
12/05/1999 12:25:55
 
 
To
11/05/1999 23:59:56
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00217461
Message ID:
00217898
Views:
25
>>>>>I would like to return both a date and a string from a form. What is a good way to do this?
>>>>>
>>>>>- return an array (possible?)
>>>>>- pass values by reference
>>>>>- other?
>>>>
>>>>Pass the form a Parameter Object. That way you can update as many values as you could possibly ever need.
>>>
>>>That sounds cool. No idea how to do it though. Any code samples you could point me to?
>>
>>
>>Define your object programmatically.
>>
>>DEFINE CLASS parameterobject AS custom
>>MyNumVal = 0
>>MyCharVal = ''
>>MyArray[5] = .f.
>>ENDDEFINE
>>
>>*
>>* Populate the parameter object's properties
>>*
>>oParam = CREATEOBJECT('parameterobject')
>>oParam.MyNumVal = 5
>>oParam.MyCharVal = 'Test string'
>>oParam.MyArray[2] = DATE()
>>oParam.MyArray[5] = 'samples'
>>*
>>* Now call your form with the object
>>*
>>DO MyForm WITH oParam
>>
>>MyForm:Init
>>LPARAMETER tobject
>>thisform.PObject = tobject
>>
>>Other methods:
>>thisform.Pobject.MyNumVal = 100
>>etc...
>>
>>
>>Your form's init event declares it is receiving the parameter and updates the values as needed. These updates can take place anywhere in your form if your form has a property to store the reference. Now, when you get back from your form, the parameter object has the updated values and you can do whatever you need to with them. Kind of like global variables, only better!
>
>PMFJI,
>
>Is there any special housekeeping you need to do once you're through with the parameter object? Or do you just issue a "RELEASE oParam" in the calling routine?

There doesn't appear to be any special housekeeping. I guess it wouldn't hurt to zap the object in the forms Destroy event code, though.

Destroy:
thisform.Pobject = .NULL.
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform