FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour OVERRIDE
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
OVERRIDE
Posted: Mon Nov 13, 2023 11:19 AM

I saw that I can modify a method of a class directly with the OVERRIDE command without having to modify the class.

Can I add Data or new methods with the same technique? and how ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: OVERRIDE
Posted: Mon Nov 13, 2023 11:25 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: OVERRIDE
Posted: Mon Nov 13, 2023 11:49 AM
Antonio Linares wrote:Dear Silvio,

Please review this:
https://github.com/harbour/core/blob/master/src/rtl/objfunc.prg

for modify a Method run ok with
Code (fw): Select all Collapse
#xcommand OVERRIDE METHOD <!Message!> [IN] CLASS <!Class!> ;
                             WITH [METHOD] <!Method!> [SCOPE <Scope>] => ;
            __clsModMsg( <Class>():classH, #<Message>, @<Method>() )
sample:
Code (fw): Select all Collapse
OVERRIDE METHOD BuildButtonBar IN CLASS TPreview WITH PreviewBuildButtonBar
I not found the #command to add data or add methods

EXTEND CLASS TPreview WITH DATA aDefaultCols not run
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: OVERRIDE
Posted: Mon Nov 13, 2023 11:52 AM
FUNCTION __objAddData( oObject, cSymbol )

it is inside:
https://github.com/harbour/core/blob/master/src/rtl/objfunc.prg
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: OVERRIDE
Posted: Mon Nov 13, 2023 12:02 PM
Antonio Linares wrote:FUNCTION __objAddData( oObject, cSymbol )

it is inside:
https://github.com/harbour/core/blob/master/src/rtl/objfunc.prg
I tried with

#xcommand EXTEND DATA <!Message!> [IN] CLASS <!Class!>
__objAddData( <Class>():classH, #<Message> )

EXTEND DATA aDefaultCols IN CLASS TPreview

not run

make error on compilation

ut_over_Bro.prg(8) Error E0007 Missing => in #translate/#command
ut_over_Bro.prg(9) Error E0030 Syntax error "syntax error at '<'"
ut_over_Bro.prg(12) Error E0030 Syntax error "syntax error at 'DATA'"
ut_over_Bro.prg(13) Error E0030 Syntax error "syntax error at 'DATA'"
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: OVERRIDE
Posted: Mon Nov 13, 2023 12:12 PM
#xcommand EXTEND DATA <!Message!> [IN] CLASS <!Class!> => ;

__objAddData( <Class>():classH, #<Message> )



seem run ok then



if I add a data sample :



EXTEND DATA aDefaultCols IN CLASS TXBrowse



give me an error



Error occurred at: 11/13/23, 13:13:45

Error description: Error BASE/3101 Argument error: __OBJADDDATA



Stack Calls

===========

Called from: => __ERRRT_BASE( 0 )

Called from: ../../../objfunc.prg => __OBJADDDATA( 0 )

Called from: ut_over_Bro.prg => UT_OVERRIDE( 12 )
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: OVERRIDE
Posted: Mon Nov 13, 2023 04:04 PM
Dear Silvio,



You add a new DATA to the object, not to the class:



#xcommand EXTEND DATA <!Message!> [IN] OBJECT <!object!> => ;

__objAddData( <object>, #<Message> )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: OVERRIDE
Posted: Tue Nov 14, 2023 08:52 AM
Antonio Linares wrote:Dear Silvio,

You add a new DATA to the object, not to the class:

#xcommand EXTEND DATA <!Message!> [IN] OBJECT <!object!> => ;
__objAddData( <object>, #<Message> )
which is the object ?

sample
If I must add a data into Txbrowse how I can make ?


EXTEND DATA aDefaultCols IN OBJECT TXBrowse

give me not found txbrowse
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: OVERRIDE
Posted: Tue Nov 14, 2023 02:03 PM
Dear Silvio,

This example works fine:
Code (fw): Select all Collapse
function Main()

   local oError := ErrorNew()
   
   __objAddData( oError, "test" )
   
   oError:test = "hello"
   ? oError:test

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion