Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Form return value
Message
 
 
To
07/08/2007 07:53:44
Alan Harris-Reid
Baseline Data Services
Devon, United Kingdom
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01246371
Message ID:
01246447
Views:
81
>Hello Naomi, thanks for the reply.
>
>>I don't think you can return a value if you exit the form from the Init.
>
>>Perhaps you can use a parameter object instead of regular parameters and return values through its properties?
>
>That's worth thinking about, but whereas I can see how to implement that for class-based forms created using oForm = CREATEOBJECT('MyForm'), how does that work for .scx-based forms called using DO FORM MyForm WITH paramlist TO MyVariable?
>
>Anyway, I've found a solution to my problem, which you and other readers might be interested in. It's not super-elegant, but it works.
>
>As you say, it appears that you cannot return a value from form.init if the Init() return value is .F. (ie. form not instantiated), even though code-execution goes directly to the Unload() event, any return value is ignored. The trick is to not return .F. in form.Init(), but let the form proceed to the Activate() event, which contains code like this...
>IF condition=quitformnow
> thisform.release
>ELSE
> DODEFAULT()
>ENDIF
>
>Regards,
>Alan

Hi Alan,

I'm not sure this is a good implementation to let form proceed to Activate.

First of all, would no return value will be enough for you to know that form's execution was stopped in the Init?

The parameter idea works the same way with class defined forms as regular forms (SCX).

E.g.

local loParamObject

* Here you can use Tore's class or your own class
do form myForm with loParamObject to myReturnValue (you don't actually need return value anymore)

form's Init
lparameters toParamObject
thisform.oParamObject = m.toParamObject
Now when you need to change any property, you just do it for thisform.oParamObject.

And when the form is released, the loParamObject has properties changed.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform