PERFECT...This is EXACTLY what I wanted to do. All I was missing was the SET PROCEDURE TO. (I use PRG classes.)
Thanks, Fernando!
On 2016-12-01 05:48, Fernando D. Bozzo wrote:
If the library will be used only by another VFP apps, then there is another approach: Using an EXE as a library, so no need to register a DLL on the clients.
*Approach 1:* Using VCX inside EXE
You just compile an EXE with your classlib and then use externally on other VFP programs. Let's say that youur library is called "mytestlib.vcx" and the class you want to instantiate is called "operations", which have methods for mathematical operations:
*- In you other VFP Apps: oOps = NEWOBJECT("operations", "mytestlib.vcx", "test_obj.exe") ? oOps.get_sum(1,2)
*Approach 2:* Using your library not as VCX, but as PRG and doing it the main program of the EXE
Let's say you have this program as the main program of the "test_obj.pjx" project:
- main_test_lib.prg
DEFINE CLASS MyClassLib as Custom FUNCTION Get_Sum(value1, value2) RETURN value1 + value2 ENDFUNC ENDDEFINE
Then, when you want to instantiate this class, you can do it this way:
SET PROCEDURE TO test_obj.exe oOps = CREATEOBJECT("myclasslib") ? oOps.get_sum(1,2)
There are other approaches, but I think that any of these can be useful to you.