dbTalk Databases Forums  

VFP6: Getting .unload()'s Return Value

comp.databases.xbase.fox comp.databases.xbase.fox


Discuss VFP6: Getting .unload()'s Return Value in the comp.databases.xbase.fox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Gene Wirchenko
 
Posts: n/a

Default VFP6: Getting .unload()'s Return Value - 07-29-2005 , 12:15 PM






I have been looking at reworking parts of my app.

1) If I have a form written in code, is there any way I can get the
return value from the form's .unload()?

2) As it stands now, my forms are modal. I am looking at changing
this. I have a few variables that I use for object references. If I
allow multiple forms to be open, that will mean that I will have to
have more than one object variable. Would I be exposing my app to
memory leak problems? What is the best way of managing multiple
objects when some can be started from inside others? I want to avoid
globals and other object internals if possible.

Sincerely,

Gene Wirchenko


Reply With Quote
  #2  
Old   
Paul Pedersen
 
Posts: n/a

Default Re: Getting .unload()'s Return Value - 07-29-2005 , 01:17 PM







"Gene Wirchenko" <genew (AT) ucantrade (DOT) com.NOTHERE> wrote

Quote:
I have been looking at reworking parts of my app.

1) If I have a form written in code, is there any way I can get the
return value from the form's .unload()?
method someform.unload:
RETURN 3

DO someform TO myvar

myvar now has 3 in it



Quote:
2) As it stands now, my forms are modal. I am looking at changing
this. I have a few variables that I use for object references. If I
allow multiple forms to be open, that will mean that I will have to
have more than one object variable.
Only if you keep form references in a variable. Without a specific reason to
do so, that's not necessary.


Quote:
Would I be exposing my app to
memory leak problems?
No. In my experience, VFP's garbage collection is pretty good. At least in
the later versions. I had some trouble with various unexplained crashes in
VFP6 & 7. I have no reason to think it was memory leaks, but no reason to
think it wasn't, either. Actually, it seemed to act more like dangling
pointers. Haven't had such problems with 8 & 9.

Keep in mind that if you create an outside reference to an object on the
form, the form cannot be released properly until you release that reference.
You will say something like THISFORM.RELEASE and the form won't go away.



Quote:
What is the best way of managing multiple
objects when some can be started from inside others? I want to avoid
globals and other object internals if possible.
Make the reference either a local variable or a property of the form.




Reply With Quote
  #3  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: Getting .unload()'s Return Value - 07-29-2005 , 01:41 PM



On Fri, 29 Jul 2005 11:17:38 -0700, "Paul Pedersen"
<no-reply (AT) swen (DOT) com> wrote:

Quote:
"Gene Wirchenko" <genew (AT) ucantrade (DOT) com.NOTHERE> wrote in message
news:msoke1t46kcmtbpp6jh3khde1slssiimoc (AT) 4ax (DOT) com...
I have been looking at reworking parts of my app.

1) If I have a form written in code, is there any way I can get the
return value from the form's .unload()?

method someform.unload:
RETURN 3

DO someform TO myvar
This syntax is not correct. If you are thinking of
do form someform to myvar
that only works with scx-based forms. I already tried it, found it
did not work, and thus my question.

Quote:
myvar now has 3 in it
[snip]

Sincerely,

Gene Wirchenko



Reply With Quote
  #4  
Old   
Dan Freeman
 
Posts: n/a

Default Re: Getting .unload()'s Return Value - 07-29-2005 , 01:57 PM



When you get away from modal forms, you also get away from the wait state
that might make a return value useful. Since you won't be anywhere in the
code near where you launched the form, where are you thinking of catching
the return value?

One approach might be to .Hide() the form, and then you can query the
object's properties before you release it. But again, I'm not sure what
value that will be without a wait state.

Dan



Gene Wirchenko wrote:
Quote:
I have been looking at reworking parts of my app.

1) If I have a form written in code, is there any way I can get the
return value from the form's .unload()?

2) As it stands now, my forms are modal. I am looking at changing
this. I have a few variables that I use for object references. If I
allow multiple forms to be open, that will mean that I will have to
have more than one object variable. Would I be exposing my app to
memory leak problems? What is the best way of managing multiple
objects when some can be started from inside others? I want to avoid
globals and other object internals if possible.

Sincerely,

Gene Wirchenko



Reply With Quote
  #5  
Old   
Jack Jackson
 
Posts: n/a

Default Re: Getting .unload()'s Return Value - 07-29-2005 , 02:25 PM



On Fri, 29 Jul 2005 11:41:23 -0700, Gene Wirchenko
<genew (AT) ucantrade (DOT) com.NOTHERE> wrote:

Quote:
On Fri, 29 Jul 2005 11:17:38 -0700, "Paul Pedersen"
no-reply (AT) swen (DOT) com> wrote:

"Gene Wirchenko" <genew (AT) ucantrade (DOT) com.NOTHERE> wrote in message
news:msoke1t46kcmtbpp6jh3khde1slssiimoc (AT) 4ax (DOT) com...
I have been looking at reworking parts of my app.

1) If I have a form written in code, is there any way I can get the
return value from the form's .unload()?

method someform.unload:
RETURN 3

DO someform TO myvar

This syntax is not correct. If you are thinking of
do form someform to myvar
that only works with scx-based forms. I already tried it, found it
did not work, and thus my question.

I do not believe there is any way to get the RETURN value.

You can pass in an object reference, save it in the called form's Init
and modify a property of the object before you release the form.

Or you can put the result in a form property, and rather than calling
Thisform.Release() set Thisform.Visible = .F. That will return
execution to the calling code and you can retrieve the return value
via the called form reference before you destroy the form.



Reply With Quote
  #6  
Old   
Jack Jackson
 
Posts: n/a

Default Re: VFP6: Getting .unload()'s Return Value - 07-29-2005 , 02:35 PM



On Fri, 29 Jul 2005 10:15:55 -0700, Gene Wirchenko
<genew (AT) ucantrade (DOT) com.NOTHERE> wrote:

Quote:
I have been looking at reworking parts of my app.

2) As it stands now, my forms are modal. I am looking at changing
this. I have a few variables that I use for object references. If I
allow multiple forms to be open, that will mean that I will have to
have more than one object variable. Would I be exposing my app to
memory leak problems? What is the best way of managing multiple
objects when some can be started from inside others? I want to avoid
globals and other object internals if possible.
Generally I use _screen.Forms() to find all of my forms.

Any form that creates an object that is owned by that form has a form
property to hold the reference to the object.

I have a single application object with a reference to it in a PUBLIC
variable. That is my only PUBLIC variable.

Objects that are common to multiple forms have their references in the
application object. Sometimes there is code in the application object
to manage these common objects (find the right one, get rid of one at
the right time, etc.).




Reply With Quote
  #7  
Old   
Paul Pedersen
 
Posts: n/a

Default Re: Getting .unload()'s Return Value - 07-29-2005 , 04:53 PM




"Gene Wirchenko" <genew (AT) ucantrade (DOT) com.NOTHERE> wrote

Quote:
On Fri, 29 Jul 2005 11:17:38 -0700, "Paul Pedersen"
no-reply (AT) swen (DOT) com> wrote:

"Gene Wirchenko" <genew (AT) ucantrade (DOT) com.NOTHERE> wrote in message
news:msoke1t46kcmtbpp6jh3khde1slssiimoc (AT) 4ax (DOT) com...
I have been looking at reworking parts of my app.

1) If I have a form written in code, is there any way I can get the
return value from the form's .unload()?

method someform.unload:
RETURN 3

DO someform TO myvar

This syntax is not correct. If you are thinking of
do form someform to myvar
that only works with scx-based forms. I already tried it, found it
did not work, and thus my question.
Sorry, I missed that part. No, you can't call DO someform if someform is not
an scx.

Try creating an object, passing it to someform as a parameter, and have the
form munge it. Then the object will have the properties you want after the
form releases.





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.