Using VF 6, I want to write a simple program to search a table for certain contents. This I can do. However I want this program to be used in a different program written in different language. Can I write a dll or anything similar in Foxpro.
Certainly. You need to write a COM DLL. Essentially, this is a VFP class which as been flagged as OLEPUBLIC. You'll find more information about how to do that in the Help.
It's best to put this class in its own project file. When you are ready to build it, click the Build button in the project manager and select the COM Server DLL option. You will end up with a DLL that you can either use immediately or distribute (and register) on your users' systems.
In general, any COM-compliant program can call the methods of your DLL, passing parameters and receiving replies as necessary. It won't matter to the caller which language the original code was in.
I hope this helps. It is just a quick overview. There is more info in the Help.
Sorry, I'm going to sound really stupid here. But all I'm doing is opening a table, selecting some data, and creating a text file. I have now forms or anything like that, just dozen or so lines in a program. Do I have to define a classs??? I've never done this before, not too sure what you mean.
Yes, you really do need to define a class. That's the only way you can get create a DLL in VFP.
There are two ways to go about it. You can write the class as a program, using DEFINE CLASS. Or you can use the visual class designer (type CREATE CLASS in the Command Window).
Silly question, is somehting like below correct then:
Dll compiled OK.
Define Class MyClass as Form OLEPUBLIC
Procedure CreateData
LPARAMETERS SEARCHDESC
set safety off
use stock in 0
SELECT STOCK
select * from STOCK into cursor temp where upper(DESCR) like "%" + SEARCHDESC +"%"
COPY TO temp.txt TYPE DELIM
USE IN STOCK
EndDefine
Then in program where dll is being used I've put :
DECLARE INTEGER CreateData IN test.DLL String
a= CreateData("O")
messagebox(str(a))
The a= CreateData("O") creates an error. This is below:
cannot find entry point CreateData in the DLL
Sorry if I sound bit silly, just can't work this out
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.