Index
2013-05-30 09:03Kent Belan : Return value from form in class
2013-05-30 09:14Ken Dibble : Re: Return value from form in class
2013-05-30 09:28Richard Kaye : RE: Return value from form in class
2013-05-30 09:32Dave Crozier : RE: Return value from form in class
2013-05-30 09:33Richard Kaye : RE: Return value from form in class
2013-05-30 09:44Kent Belan : RE: Return value from form in class
2013-05-30 14:50MB Software Solutions, LLC : Re: Return value from form in class
Back to top
Return value from form in class

Author: Kent Belan

Posted: 2013-05-30 09:03:35   Link

Hello,

I am trying to build a form in a class. Everything is working ok, but now

I want to return a value from the form.

How do I get the return value passed back to the calling form ?

Here is my code:

oForm = createobject("testform")

oForm.show(1)

lcReturnMsg = oForm.cReturnMsg

The problem is the 3rd line errors out with oForm not valid because the form

has already released

So what is the trick to return a value from a form in a class ?

Thanks,

Kent

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox

OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/003e01ce5d3e$7b363a30$71a2ae90$@mchsi.com

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2013 Kent Belan
Back to top
Re: Return value from form in class

Author: Ken Dibble

Posted: 2013-05-30 09:14:18   Link

>I am trying to build a form in a class. Everything is working ok, but now

>I want to return a value from the form.

>

>How do I get the return value passed back to the calling form ?

>

>Here is my code:

>

>oForm = createobject("testform")

>oForm.show(1)

>lcReturnMsg = oForm.cReturnMsg

>

>The problem is the 3rd line errors out with oForm not valid because the form

>has already released

>

>So what is the trick to return a value from a form in a class ?

Typically I do something like this (untested and no error-trapping, but

enough to give the gist):

DEFINE CLASS Form1 AS Form

ModalResult = ""

PROCEDURE LaunchForm2

oForm = CREATEOBJECT("Form2",THISFORM)

oForm.Show(1)

* Do something with THISFORM.ModalResult here....

ENDPROC

ENDDEFINE

DEFINE CLASS Form2 AS Form

ReturnValue = ""

Caller = .NULL.

PROCEDURE Init

LPARAMETERS oCaller

THIS.Caller = oCaller

ENDPROC

PROCEDURE DoSomethingUseful

THIS.ReturnValue = "Foo"

ENDPROC

PROCEDURE UNLOAD

oCaller.ModalResult = THIS.ReturnValue

ENDPROC

ENDDEFINE

Ken Dibble

www.stic-cil.org

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox

OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/5.2.1.1.1.20130530100632.01cccff8@POP-Server.stny.rr.com

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2013 Ken Dibble
Back to top
RE: Return value from form in class

Author: Richard Kaye

Posted: 2013-05-30 09:28:21   Link

One way to do it would be to declare your lcReturnMsg variable as private before creating your form object and then directly set that variable in the unload of the form. Another way would be to pass a reference to the calling form object (implied in your question but not shown) to your called form. You would want to have a mechanism for passing object references between your forms/classes. This assumes the thing you want to manipulate is a property of the original form.

--

rk

-----Original Message-----

From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Kent Belan

Sent: Thursday, May 30, 2013 10:04 AM

To: profoxtech@leafe.com

Subject: Return value from form in class

Hello,

I am trying to build a form in a class. Everything is working ok, but now I want to return a value from the form.

How do I get the return value passed back to the calling form ?

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox

OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/DF1EEF11E586A64FB54A97F22A8BD044227EB9222E@ACKBWDDQH1.artfact.local

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2013 Richard Kaye
Back to top
RE: Return value from form in class

Author: Dave Crozier

Posted: 2013-05-30 09:32:38   Link

Kent,

As Ken has said, set up the return variable in the Unload() of the form either that or you can actually do return <return_variable> in the Unload.

Personally I never pass back discrete variable but pass in/out a parameter "object" populated with various properties that I may need to use, change or pass back. Limiting yourself to passing one variable can be a real pain and you end up passing strings of made up parameters with delimiters etc etc..

Dave

-----Original Message-----

From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Kent Belan

Sent: 30 May 2013 15:04

To: 'ProFox Email List'

Subject: Return value from form in class

Hello,

I am trying to build a form in a class. Everything is working ok, but now I want to return a value from the form.

How do I get the return value passed back to the calling form ?

Here is my code:

oForm = createobject("testform")

oForm.show(1)

lcReturnMsg = oForm.cReturnMsg

The problem is the 3rd line errors out with oForm not valid because the form has already released

So what is the trick to return a value from a form in a class ?

Thanks,

Kent

[excessive quoting removed by server]

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox

OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/18725B8CD2D5D247873A2BAF401D4AB20565EE55@EX2010-A-FPL.FPL.LOCAL

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2013 Dave Crozier
Back to top
RE: Return value from form in class

Author: Richard Kaye

Posted: 2013-05-30 09:33:24   Link

The latter being what Ken illustrated, of course.

--

rk

-----Original Message-----

From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Richard Kaye

Sent: Thursday, May 30, 2013 10:28 AM

To: profoxtech@leafe.com

Subject: RE: Return value from form in class

One way to do it would be to declare your lcReturnMsg variable as private before creating your form object and then directly set that variable in the unload of the form. Another way would be to pass a reference to the calling form object (implied in your question but not shown) to your called form. You would want to have a mechanism for passing object references between your forms/classes. This assumes the thing you want to manipulate is a property of the original form.

--

rk

-----Original Message-----

From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Kent Belan

Sent: Thursday, May 30, 2013 10:04 AM

To: profoxtech@leafe.com

Subject: Return value from form in class

Hello,

I am trying to build a form in a class. Everything is working ok, but now I want to return a value from the form.

How do I get the return value passed back to the calling form ?

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox

OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/DF1EEF11E586A64FB54A97F22A8BD044227EB92237@ACKBWDDQH1.artfact.local

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2013 Richard Kaye
Back to top
RE: Return value from form in class

Author: Kent Belan

Posted: 2013-05-30 09:44:13   Link

Hello Ken,

Thanks very much for the quick reply.

I had no idea I could pass parameters like that.

Probably should have looked in the help ...

Thanks also to Richard and Dave.

This is the best resource anywhere ... thanks Ed !!

-----Original Message-----

From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Ken Dibble

Sent: Thursday, May 30, 2013 10:14 AM

To: profox@leafe.com

Subject: Re: Return value from form in class

>I am trying to build a form in a class. Everything is working ok, but

>now I want to return a value from the form.

>

>How do I get the return value passed back to the calling form ?

>

>Here is my code:

>

>oForm = createobject("testform")

>oForm.show(1)

>lcReturnMsg = oForm.cReturnMsg

>

>The problem is the 3rd line errors out with oForm not valid because the

>form has already released

>

>So what is the trick to return a value from a form in a class ?

Typically I do something like this (untested and no error-trapping, but

enough to give the gist):

DEFINE CLASS Form1 AS Form

ModalResult = ""

PROCEDURE LaunchForm2

oForm = CREATEOBJECT("Form2",THISFORM)

oForm.Show(1)

* Do something with THISFORM.ModalResult here....

ENDPROC

ENDDEFINE

DEFINE CLASS Form2 AS Form

ReturnValue = ""

Caller = .NULL.

PROCEDURE Init

LPARAMETERS oCaller

THIS.Caller = oCaller

ENDPROC

PROCEDURE DoSomethingUseful

THIS.ReturnValue = "Foo"

ENDPROC

PROCEDURE UNLOAD

oCaller.ModalResult = THIS.ReturnValue

ENDPROC

ENDDEFINE

Ken Dibble

www.stic-cil.org

[excessive quoting removed by server]

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox

OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/004701ce5d44$285dd380$79197a80$@mchsi.com

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2013 Kent Belan
Back to top
Re: Return value from form in class

Author: MB Software Solutions, LLC

Posted: 2013-05-30 14:50:47   Link

On 5/30/2013 10:03 AM, Kent Belan wrote:

> Hello,

>

> I am trying to build a form in a class. Everything is working ok, but now

> I want to return a value from the form.

>

> How do I get the return value passed back to the calling form ?

>

> Here is my code:

>

> oForm = createobject("testform")

> oForm.show(1)

> lcReturnMsg = oForm.cReturnMsg

>

> The problem is the 3rd line errors out with oForm not valid because the form

> has already released

>

> So what is the trick to return a value from a form in a class ?

Kent,

The others already mentioned the Unload way. I actually sometimes just

do a HIDE in the called form and then from the caller I do a release.

So for example:

do form frmSomething name loFrm

loFrm.Show()

if loFrm.lOK then

lcValue = loFrm.cPropertyThatHasValue

endif

loFrm.release()

Just another way. Allows me to handle/grab several values of the called

form too instead of dealing with parameter object approach.

hth,

--Mike

--

Mike Babcock, MCP

MB Software Solutions, LLC

President, Chief Software Architect

http://mbsoftwaresolutions.com

http://fabmate.com

http://twitter.com/mbabcock16

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox

OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/51A7AD97.4070700@mbsoftwaresolutions.com

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2013 MB Software Solutions, LLC