DEFINE CLASS myclass AS session PROCEDURE GetOrderDate LPARAMETERS tcOrderNumber LOCAL ldReturn ldReturn = {} USE home(2) + "Tastrade\Data\orders.dbf" if seek(padl(tcOrderNumber, 6), 'orders', 'order_numb') ldReturn = order_date endif USE RETURN ldReturn ENDDEFINEI can now call this class like this:
oClass = createobject('myclass') ?oClass.GetOrderDate(1075)Now lets make this VFP specific class into a multi langauge COM object. I'm going to add the OLEPUBLIC keyword to the class defintion, plus, I'll use new VFP7 syntax to define what type of parameters and return values my method expects. Everything else will stay the same:
DEFINE CLASS myclass AS session OLEPUBLIC PROCEDURE GetOrderDate(tcOrderNumber AS string) AS date LOCAL ldReturn ldReturn = {} USE home(2) + "Tastrade\Data\orders.dbf" if seek(padl(tcOrderNumber, 6), 'orders', 'order_numb') ldReturn = order_date endif USE RETURN ldReturn ENDDEFINEIf I add this code to a project and compile the project as a DLL, I can now run my code from any COM enabled language (VB, Delphi, VFP, VBScript, ASP, ect.)
oCOM = createobject('projectname.myclass') ?oCOM.GetOrderDate(1075)Now, I can take my Class, and move it to the next level, Web services, by running the Web Service Publisher in VFP7. This will create some supporting files, like WSDL, and maybe an ASP page. Web services can be used by any platform that support HTTP and XML (I can't think of one that doesn't, since XML it just text with angle brackets around it < >).
oWebService = CREATEOBJECT('mssoap.soapclient') oWebService.mssoapinit('http://www.myserver.net/myclass.wsdl') ?oWebService.GetOrderDate(1075)Anyone can call your class from anywhere in the world with an internet connection. So, if I had a URL to your WSDL file, I would call your Web Service with parameters, the class will execute completely on your computer, and the return value will be sent back to my computer, all through the internet.