Index
2012-06-14 08:56Kent Belan : Call form inside project from from ouside project
2012-06-14 09:21Tracy Pearson : RE: Call form inside project from from ouside project
2012-06-15 05:47Christof Wollenhaupt : Re: Call form inside project from from ouside project
2012-06-15 07:32Kent Belan : RE: Call form inside project from from ouside project
2012-06-15 07:35Kent Belan : RE: Call form inside project from from ouside project
2012-06-15 08:09Kent Belan : RE: Call form inside project from from ouside project
Back to top
Call form inside project from from ouside project

Author: Kent Belan

Posted: 2012-06-14 08:56:55   Link

Hello,

This is kind of complicated, but I am trying to build a custom report module

that will allow for data entry forms and reports to be created external of

the project/application but still run from inside the application.

I have this working ok, but here is my problem. I want to call a form that

is inside the project, but the external form does not see the form inside

the project.

So from inside the project/application, I have a DBF that contains the

external custom reports. I create a menu from this list of external reports

and allow the user to select a report to run.

The code to run the external form looks something like:

External form (oApp.DataPath + 'CustomReports\' + trim(tReports.rptform))

Do form oApp.DataPath + 'CustomReports\' + trim(tReports.rptform)

This works great. The problem I am having is from inside this external form,

I want to call a generic print_preview form that is inside the project

So from inside the external form:

Do form Print_Preview with 'ReportName'

This causes an error because it can not find the form.

Is there anyway to call a form that is inside a project/application from a

form that is external to the application ?

Thanks,

Kent

_______________________________________________

Post Messages to: ProFox@leafe.com

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

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

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

This message: http://leafe.com/archives/byMID/profox/4A92DBD0D8F54051BE8F90B799E73EF8@LaptopW7

** 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.

©2012 Kent Belan
Back to top
RE: Call form inside project from from ouside project

Author: Tracy Pearson

Posted: 2012-06-14 09:21:25   Link

Kent Belan wrote on 2012-06-14:

> Hello,

>

> This is kind of complicated, but I am trying to build a custom report

module

> that will allow for data entry forms and reports to be created external

of

> the project/application but still run from inside the application.

>

> I have this working ok, but here is my problem. I want to call a form

that

> is inside the project, but the external form does not see the form inside

> the project.

>

> So from inside the project/application, I have a DBF that contains the

> external custom reports. I create a menu from this list of external

reports

> and allow the user to select a report to run.

>

> The code to run the external form looks something like:

>

> External form (oApp.DataPath + 'CustomReports\' + trim(tReports.rptform))

> Do form oApp.DataPath + 'CustomReports\' + trim(tReports.rptform)

>

> This works great. The problem I am having is from inside this external

form,

> I want to call a generic print_preview form that is inside the project

>

> So from inside the external form:

>

> Do form Print_Preview with 'ReportName'

>

> This causes an error because it can not find the form.

>

> Is there anyway to call a form that is inside a project/application from

a

> form that is external to the application ?

>

> Thanks,

> Kent

>

Kent,

I'm not sure if it will work from inside the EXE and carry to outside the

EXE, but you could use this to try:

SET PROCEDURE TO (_VFP.SERVERNAME) ADDITIVE

Do this once sometime early in the program before calling the external

forms. (or for testing, add it just before the call)

Tracy Pearson

PowerChurch Software

_______________________________________________

Post Messages to: ProFox@leafe.com

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

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

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

This message: http://leafe.com/archives/byMID/profox/000401cd4a38$fb5c8120$f2158360$@powerchurch.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.

©2012 Tracy Pearson
Back to top
Re: Call form inside project from from ouside project

Author: Christof Wollenhaupt

Posted: 2012-06-15 05:47:45   Link

>

> This works great. The problem I am having is from inside this external

> form,

> I want to call a generic print_preview form that is inside the project

>

What you've come across is application scope. The resolution of embedded

file names only works from within code that is attached to the same

application scope. Hence, the short answer to your problem is that you need

to call the form from within code of the main application. There are

multiple options:

a) Specify a parameter in your main program to allow multiple ways of

calling the application:

LPARAMETER tcCmd

DO CASE

CASE Empty(m.tcCmd)

* default behavior

CASE m.tcCmd == "preview" and PROGRAM(-1) != 1

DO FORM ReportPreview.SCX

OTHERWISE

* error message

ENDCASE

Then you can call your preview form by executing the main EXE

DO myApp.EXE WITH "preview"

b) The NEWOBJECT() function has a third parameter to specify the EXE.

Instead of running the form directly, you could use a ReportPreview class

that runs the form. When the function was introduced way back NEWOBJECT()

would cause dangling references to class libraries when those were loaded

from a different application. This might be fixed already. If you use ReFox

or similar tools, this approach will only work for the main EXE itself.

c) Pass a reference to an helper object to the form. If you create an

object in the main application and pass it to the reporting form, the

helper object still runs in the main application scope even when called

from the external form. This object would then execute the report preview.

Instead of an helper object you can use a method in the application object,

if your app has a goApp object and you don't mind the tighter coupling.

d) Rely on caching and loaded files. SET PROCEDURE and SET CLASSLIB make

files available to the instance, same with the calling stack and called

procedures. Most of those are available from external forms, too, because

it doesn't require to resolve an external file name when the code is

already loaded. However, there are subtle problems when code is unloaded or

the caching order changes. For this to work, everything must have a unique

name. If your external forms use the same classes as your main application,

they must have a different name.

e) Make the preview form an external file, too. You could copy the SCX/SCT

file into the temporary directory if it doesn't rely on any further

embedded files.

f) Convert the preview SCX into a VCX class and then use one of the options

above.

Christof

--- StripMime Report -- processed MIME parts ---

multipart/alternative

text/plain (text body -- kept)

text/html

---

_______________________________________________

Post Messages to: ProFox@leafe.com

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

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

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

This message: http://leafe.com/archives/byMID/profox/CAL4QJhjUB6SoNmx_HZSc1cgXaNLdqPAR3OuUCin9s-SJ7hrKcw@mail.gmail.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.

©2012 Christof Wollenhaupt
Back to top
RE: Call form inside project from from ouside project

Author: Kent Belan

Posted: 2012-06-15 07:32:15   Link

Hello Tracy,

Thanks for your idea, I tried it, but did not have any luck.

The program can not find the form in the current folder.

I have it working by making a copy of the print_preview form in the

customreports folder.

Not exactly what I wanted, but it is working.

Thanks,

Kent

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

From: profox-bounces@leafe.com [mailto:profox-bounces@leafe.com] On Behalf

Of Tracy Pearson

Sent: Thursday, June 14, 2012 10:21 AM

To: profox@leafe.com

Subject: RE: Call form inside project from from ouside project

Kent Belan wrote on 2012-06-14:

> Hello,

>

> This is kind of complicated, but I am trying to build a custom report

module

> that will allow for data entry forms and reports to be created

> external

of

> the project/application but still run from inside the application.

>

> I have this working ok, but here is my problem. I want to call a form

that

> is inside the project, but the external form does not see the form

> inside the project.

>

> So from inside the project/application, I have a DBF that contains

> the external custom reports. I create a menu from this list of

> external

reports

> and allow the user to select a report to run.

>

> The code to run the external form looks something like:

>

> External form (oApp.DataPath + 'CustomReports\' +

> trim(tReports.rptform)) Do form oApp.DataPath + 'CustomReports\' +

> trim(tReports.rptform)

>

> This works great. The problem I am having is from inside this

> external

form,

> I want to call a generic print_preview form that is inside the

> project

>

> So from inside the external form:

>

> Do form Print_Preview with 'ReportName'

>

> This causes an error because it can not find the form.

>

> Is there anyway to call a form that is inside a project/application

> from

a

> form that is external to the application ?

>

> Thanks,

> Kent

>

Kent,

I'm not sure if it will work from inside the EXE and carry to outside the

EXE, but you could use this to try:

SET PROCEDURE TO (_VFP.SERVERNAME) ADDITIVE

Do this once sometime early in the program before calling the external

forms. (or for testing, add it just before the call)

Tracy Pearson

PowerChurch Software

[excessive quoting removed by server]

_______________________________________________

Post Messages to: ProFox@leafe.com

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

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

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

This message: http://leafe.com/archives/byMID/profox/F2635505F1FE473CBA831E2EA756168B@LaptopW7

** 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.

©2012 Kent Belan
Back to top
RE: Call form inside project from from ouside project

Author: Kent Belan

Posted: 2012-06-15 07:35:32   Link

Hello Christof,

Thanks so much for your several suggestions on ways this might work.

I really like the idea of using the oApp global application object to make

the call to the print_preview form.

If I understand correctly, the custom report will call a method in the oApp

object that will then call the print_preview form.

I am going to try this now, hope it works.

Thanks,

Kent

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

From: profox-bounces@leafe.com [mailto:profox-bounces@leafe.com] On Behalf

Of Christof Wollenhaupt

Sent: Friday, June 15, 2012 6:48 AM

To: profox@leafe.com

Subject: Re: Call form inside project from from ouside project

>

> This works great. The problem I am having is from inside this external

> form, I want to call a generic print_preview form that is inside the

> project

>

What you've come across is application scope. The resolution of embedded

file names only works from within code that is attached to the same

application scope. Hence, the short answer to your problem is that you need

to call the form from within code of the main application. There are

multiple options:

a) Specify a parameter in your main program to allow multiple ways of

calling the application:

LPARAMETER tcCmd

DO CASE

CASE Empty(m.tcCmd)

* default behavior

CASE m.tcCmd == "preview" and PROGRAM(-1) != 1

DO FORM ReportPreview.SCX

OTHERWISE

* error message

ENDCASE

Then you can call your preview form by executing the main EXE

DO myApp.EXE WITH "preview"

b) The NEWOBJECT() function has a third parameter to specify the EXE.

Instead of running the form directly, you could use a ReportPreview class

that runs the form. When the function was introduced way back NEWOBJECT()

would cause dangling references to class libraries when those were loaded

from a different application. This might be fixed already. If you use ReFox

or similar tools, this approach will only work for the main EXE itself.

c) Pass a reference to an helper object to the form. If you create an object

in the main application and pass it to the reporting form, the helper object

still runs in the main application scope even when called from the external

form. This object would then execute the report preview.

Instead of an helper object you can use a method in the application object,

if your app has a goApp object and you don't mind the tighter coupling.

d) Rely on caching and loaded files. SET PROCEDURE and SET CLASSLIB make

files available to the instance, same with the calling stack and called

procedures. Most of those are available from external forms, too, because it

doesn't require to resolve an external file name when the code is already

loaded. However, there are subtle problems when code is unloaded or the

caching order changes. For this to work, everything must have a unique name.

If your external forms use the same classes as your main application, they

must have a different name.

e) Make the preview form an external file, too. You could copy the SCX/SCT

file into the temporary directory if it doesn't rely on any further embedded

files.

f) Convert the preview SCX into a VCX class and then use one of the options

above.

Christof

--- StripMime Report -- processed MIME parts --- multipart/alternative

text/plain (text body -- kept)

text/html

---

[excessive quoting removed by server]

_______________________________________________

Post Messages to: ProFox@leafe.com

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

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

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

This message: http://leafe.com/archives/byMID/profox/53E16F0711B94716A02FD4FDAD0B4085@LaptopW7

** 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.

©2012 Kent Belan
Back to top
RE: Call form inside project from from ouside project

Author: Kent Belan

Posted: 2012-06-15 08:09:58   Link

Hello Christof,

Just wanted to say THANK YOU !!

That worked great, you are making me look good.

I can now create custom forms and reports and run them external of the EXE

This list is the Best

Thanks Ed for this great resource

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

From: profox-bounces@leafe.com [mailto:profox-bounces@leafe.com] On Behalf

Of Kent Belan

Sent: Friday, June 15, 2012 8:36 AM

To: 'ProFox Email List'

Subject: RE: Call form inside project from from ouside project

Hello Christof,

Thanks so much for your several suggestions on ways this might work.

I really like the idea of using the oApp global application object to make

the call to the print_preview form.

If I understand correctly, the custom report will call a method in the oApp

object that will then call the print_preview form.

I am going to try this now, hope it works.

Thanks,

Kent

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

From: profox-bounces@leafe.com [mailto:profox-bounces@leafe.com] On Behalf

Of Christof Wollenhaupt

Sent: Friday, June 15, 2012 6:48 AM

To: profox@leafe.com

Subject: Re: Call form inside project from from ouside project

>

> This works great. The problem I am having is from inside this external

> form, I want to call a generic print_preview form that is inside the

> project

>

What you've come across is application scope. The resolution of embedded

file names only works from within code that is attached to the same

application scope. Hence, the short answer to your problem is that you need

to call the form from within code of the main application. There are

multiple options:

a) Specify a parameter in your main program to allow multiple ways of

calling the application:

LPARAMETER tcCmd

DO CASE

CASE Empty(m.tcCmd)

* default behavior

CASE m.tcCmd == "preview" and PROGRAM(-1) != 1

DO FORM ReportPreview.SCX

OTHERWISE

* error message

ENDCASE

Then you can call your preview form by executing the main EXE

DO myApp.EXE WITH "preview"

b) The NEWOBJECT() function has a third parameter to specify the EXE.

Instead of running the form directly, you could use a ReportPreview class

that runs the form. When the function was introduced way back NEWOBJECT()

would cause dangling references to class libraries when those were loaded

from a different application. This might be fixed already. If you use ReFox

or similar tools, this approach will only work for the main EXE itself.

c) Pass a reference to an helper object to the form. If you create an object

in the main application and pass it to the reporting form, the helper object

still runs in the main application scope even when called from the external

form. This object would then execute the report preview.

Instead of an helper object you can use a method in the application object,

if your app has a goApp object and you don't mind the tighter coupling.

d) Rely on caching and loaded files. SET PROCEDURE and SET CLASSLIB make

files available to the instance, same with the calling stack and called

procedures. Most of those are available from external forms, too, because it

doesn't require to resolve an external file name when the code is already

loaded. However, there are subtle problems when code is unloaded or the

caching order changes. For this to work, everything must have a unique name.

If your external forms use the same classes as your main application, they

must have a different name.

e) Make the preview form an external file, too. You could copy the SCX/SCT

file into the temporary directory if it doesn't rely on any further embedded

files.

f) Convert the preview SCX into a VCX class and then use one of the options

above.

Christof

--- StripMime Report -- processed MIME parts --- multipart/alternative

text/plain (text body -- kept)

text/html

---

[excessive quoting removed by server]

_______________________________________________

Post Messages to: ProFox@leafe.com

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

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

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

This message: http://leafe.com/archives/byMID/profox/1A7D9449E6A4496F981C73F647F2FA13@LaptopW7

** 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.

©2012 Kent Belan