×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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

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

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
https://www.doschke.name

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

(OP)
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! smile)

Thank you very much!
Rajesh

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

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

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

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
https://www.doschke.name

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close