FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Add a Method on specific class
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Add a Method on specific class
Posted: Thu May 07, 2015 11:01 AM

IT is possible to Add a Method on specific class from a prg ?

With OVERRIDE COMMAND I can change a method

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: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Add a Method on specific class
Posted: Thu May 07, 2015 02:47 PM

Create a new class, inherit from the one you wish to add to, and add your methods.

Example: tData inherits from tDatabase and both adds, and overrides, some methods from the primary class.

I have created classes that inherit from tData but add specific methods. For example, I can create an Inventory class that inherits from tData, and is used to call the inventory database. I can then add methods which enhance that class.

James Bott has two white papers on the subject that are referenced in this forum many times.

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Add a Method on specific class
Posted: Thu May 07, 2015 04:04 PM

Silvio,

This is also possible in Harbour:

include "hbclass.ch"

include "c:\harbour\contrib\xhb\xhbcls.ch"

EXTEND CLASS ClassName WITH DATA DataName

and

EXTEND CLASS ClassName WITH MESSAGE MessageName( param, ... )

It does not follow OOP rules but it works also :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion