DEFINE CLASS sampleclass AS CUSTOM OLEPUBLIC
NAME = "sampleclass"
*!* GenError accepts one numeric parameter, which is the error number
*!* of the Visual FoxPro (VFP) error to generate.
PROCEDURE GenError
LPARAMETERS nError
*!* This raises the error.
ERROR nError
ENDPROC
*!* When the error is generated, it triggers the Error event, which
*!* creates a return statement to pass back to the client.
PROCEDURE Error
LPARAMETERS nError, cMethod, nLine
LOCAL lcRetVal
lcRetVal = ALLTRIM(STR(nError)) + ": " + MESSAGE() + ;
" on Line " + ALLTRIM(STR(nLine)) + ;
" in the sample DLL that was created for this article"
COMRETURNERROR(cMethod, lcRetVal)
ENDPROC
ENDDEFINE
*-- Calling sample:
oX = CreateObject('Mysample.sampleclass')
oX.generror(1)
|