Can someone help me understand instanciating vfp projects?

59 Views Asked by At

I have a vfp project, call it Proj2. It contains some methods that accept paramaters and returns results. Let's say it has a method named addtwonumbers and a method named subtracttwonumbers.

I have another vfp project, call it Proj1. Proj1 instanciates Proj2 by doing loProj2Reference=createobject("proj2")

I need to call Proj2's addtwonumbers method so I do something like x=loProj2Reference.addtwonumbers(1,2)

What is in Proj2 that lets it stay alive so that Proj1 can call it's methods? If in the main prg of Proj2, there is a endless loop, when I instanciate Proj2 from Proj1, it never returns from the line, loProj2Reference=createobject("proj2"). So that does not work. If in the main prg of Proj2 there is a read events, same problem.

So, again, what is in Proj2 that allows it to stay alive so I can call it's methods? I know that if Proj2 is a COM server, this is all doable but if it is NOT a COM server, is this possible?

The answer may very well be that I am way off base and that there is a much better way to look at making use of Proj2's methods from Proj1.

I should also tell you that Proj2 is a VFP project developed using the VFExpress framework. For VFE apps, the application object is the main.prg so I am really instanciating the "Proj2applicationobject" which has no user interface. The reason I am doing this is my VFE framework gives me lots of tools for business objects etc. Proj1 is a regular VFP project. Let' say it has a user interface and needs access to all that data/business object functionality that is in Proj2.

Thanks, John

0

There are 0 best solutions below