Article ID: 157049
Article Last Modified on 7/1/2004
* TaxLib.PRG
DEFINE CLASS taxes AS custom
PROCEDURE gettaxes
LPARAMETER cState
DO CASE
CASE m.cState = "CA"
RETURN .08
CASE m.cState = "WA"
RETURN .07
CASE m.cState = "NY"
RETURN .10
OTHERWISE
RETURN 0
ENDCASE
ENDPROC
ENDCLASS
Your application can test this class within Visual FoxPro internally
with code similar to the following:
cState = "CA"
nBookPrice = 19.95
SET PROCEDURE TO TaxLib && can also use SET CLASS
oTaxes = CreateObject("Taxes")
nBookTax = oTaxes.GetTaxes(m.cState) * m.nBookPrice
? "Book total: "+ALLTRIM(STR(m.nBookPrice+m.nBookTax))
The advantage here is that you are working within the Visual FoxPro
development environment so you can take advantage of the debugger for
common errors such as "Syntax Error."
DEFINE CLASS taxes AS custom
To:
DEFINE CLASS taxes AS custom OLEPUBLIC
NOTE: If you are using a visual class created in a .vcx file, you would
go into the Class Info dialog box to select the OLE Public check box.
cState = "CA"
nBookPrice = 19.95
oTaxes = CreateObject("Books.Taxes")
nBookTax = oTaxes.GetTaxes(m.cState) * m.nBookPrice
? "Book total: "+ALLTRIM(STR(m.nBookPrice+m.nBookTax))
You should not encounter many problems beyond step 1; however, there are
a few things to look out for. Since the OLE Server uses the run-time
version, not all the language is supported (especially some of the user
interface and designers). Make sure you avoid commands that do not work
with the run-time version (these are documented in the Visual FoxPro
Professional Features Guide, under "Distributing Applications").
OLEServerBusyTimeout
OLERequestPendingTimeout
OLEServerBusyRaiseError
StartMode
* Client code
x=create("myproj.myserver")
y=create("form")
x.test(y) &&generates error because of blocking
* Server code in project Myproj
DEFINE CLASS myserver AS custom OLEPUBLIC
PROCEDURE test
PARAMETER oForm
oForm.Caption = "Hello World"
ENDPROC
ENDDEFINE
There are a number of ways to successfully handle OLE Callbacks. One is
with the use of Timers (see the Pool Manager sample located in
Samples\Servers).
Keywords: kbhowto kbinterop kbautomation kbcode KB157049