>>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
>
Hi Antonio,
If I may ask you a follow up question, please.
The class that I am creating, by subclassing, will be used in a Form. And the custom method that will have "my" code will have a reference to the form (e.g. thisform.) Which causes the error.
How do I use this subclassed object in the Form so that the custom method would be able to reference the Thisform?
UPDATE: I think I need to instantiate the class in the INIT of this method using NewObject().
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham