>Hi,
>
>I have a class defined in a prg file (e.g. MyClass.prg). I need to subclass it so that I can replace the code in one of the methods with my custom code.
>
>How do you do it?
>
>TIA
Dmitry,
At the time of the subclass definition, the upper class must be in scope by a SET PROCEDURE TO MyClass.prg. You must create a new prg (assuming you don't want to change the original one) in which you just redefine what needs to be changed.
For instance, this being MyClass.prg
DEFINE CLASS SomeClass AS Custom
FUNCTION Method_One
LPARAMETERS Parm1 AS Number, Parm2 AS Number
RETURN m.Parm1 * m.Parm2
ENDFUNC
FUNCTION Method_Two
LPARAMETERS Parm1 AS Number, Parm2 AS Number
RETURN m.Parm1 / m.Parm2
ENDFUNC
END DEFINE
you may write a different MySubClass.prg with
DEFINE CLASS SomeSubClass AS SomeClass
FUNCTION Method_Two
LPARAMETERS Parm1 AS Number, Parm2 AS Number
RETURN IIF(m.Parm2 = 0, .NULL., m.Parm1 / m.Parm2)
ENDFUNC
END DEFINE
----------------------------------
António Tavares Lopes