Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can we save a form in APP and call it from outside (say a PRG file) ? 2

Status
Not open for further replies.

Rajesh Karunakaran

Programmer
Sep 29, 2016
549
MU
Hi Team!

I want to save/store a few forms of my application in an APP file and then call it from menu/prg file.
The DO FORM command doesn't have a 'IN' clause as in the DO command.

The idea is that if there is any change in the form, I will just modify the APP and can send to my client without having to do anything in the base EXE file.

Can this be done? Is there any alternative?

Thanks in advance
Rajesh
 
Well, use VFP in the object-oriented way, then you can make use of NewObject() with all its parameters, not only having the cInModule but also cInApplicatoin parameter.

Say you store a form class myform into a class library myforms.vcx and compile that into an app mylibs.app, then you can do:

Code:
oForm = NewObject("myform","myforms","mylibs.app")
oForm.Show()
The cInApplication parameter can also be an EXE, by the way. It gets a bit confusing, as objects created this way still are part of the calling EXE process, you don't start e new process this way. So APP files are a good idea.

Also, further parameters of NewObject after the cInApplication parameter are forwarded to the Init() of myform.

There's a slight hurdle of form classes vs forms, a form class can't have a data environment, if you use that you can add a data environment class to the form class, though.

There are further possibilities, as you can compile PRGs into an app and call them with DO, so you can have a PRG inside the APP which does a DO FORM of a form also included in the APP file, so you can stay with SCX forms embedded in APPs.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Olaf!

That last para is certainly a great idea! Let me try that.
However, I may take some time to do it and get back here.
So, please be still good to me if I am not around with this for sometime! :))

Thank you very much!
Rajesh
 
Hi Rajesh,

Olaf has given you some good advice. But just to give you another option to consider:

Write a PRG that receives a parameter. The parameter would be the name of the form you wish to run (e.g. CustForm). The PRG would look something like this:

Code:
LPARAMETERS tcForm

DO FORM (tcForm)

RETURN

Obviously that's a simplification. You would need some code to initialise the environment, open tables, handle errors, etc. But it should give you the general idea.

Next, build the PRG into an APP. Call it, say, MyForms.APP. Then, when you want to run a form:

Code:
DO MyForms.app WITH "CustForm"

Having said that, it's not clear why you need the app. It would be easier to simply launch the form in the usual way. But I assume you have a good reason for not wanting to do that.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Of course, you only need such a small PRG to call any form, so I don't know why you'd say "I may take some time to do it and get back here." Even if you'd just write a specific PRG with DO FORM some.scx without parameter, it doesn't take much time to try this and then refine it to your needs.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top