I'm creating a wrapper class for a commercial ActiveX control.
Rather than code a Method for each function, I created the OnError handler below to attempt to post any unknown message as a call to the actual control. It seems to work, but there are a couple issues:
How can I handle passing non-string args? In PRG code, can I "push items onto the stack" and exec the Do() method?
Is there a better way to do this, or do you see a lurking problem?
- Code: Select all Expand view
METHOD OnError( ... ) CLASS XXXView
static lInErrorAlready := .f.
local cMsg := __GetMessage(), cCmd, x
private oSelf := Self
IF lInErrorAlready
_ClsSetError( _GenError( 1004, ::ClassName(), cMsg ) )
ELSE
lInErrorAlready := .t.
cCmd := "oSelf:Do('"+ cMsg
FOR EACH x IN HB_aParams()
cCmd += "','" + x
NEXT
cCmd += "')"
&cCmd
ENDIF
lInErrorAlready := .F.
RETURN nil