FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to inherit from 7.12's rpreview class?
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
How to inherit from 7.12's rpreview class?
Posted: Wed Jan 02, 2008 02:49 AM
I have a customized version of rpreview, which has a few additional buttons.

Seeing that rpreview in 7.12 is now a class, I attempt to inherit from it and place my changes in this new class. So I create a new class TPreview2, copy over method ::BuildButtonBar() and started to add in the additional buttons.

What stump me during this attempt is l2007 is declared as a static var in TPreview not as a class data. What's the correct way for me to proceed? Simply create a static l2007 var in TPreview2 or modify TPreview and change the var to a class data?

What's actually the rule of thumb when inheriting classes that make use of static vars? TPrinter is another class that comes to mind.

TIA
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How to inherit from 7.12's rpreview class?
Posted: Wed Jan 02, 2008 12:19 PM

Hua,

> What's the correct way for me to proceed?

Yes, you can declare it as a CLASSDATA and modify the source code to access ::l2007

There is nothing wrong in using static vars. The problem comes when a class is inherited, as in your case. Then, you are right, a CLASSDATA is the way to go

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
How to inherit from 7.12's rpreview class?
Posted: Wed Jan 02, 2008 12:41 PM

Antonio,

what is the difference between CLASSDATA and DATA ?
When I have to use CLASSDATA ?

kind regards

Stefan
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How to inherit from 7.12's rpreview class?
Posted: Wed Jan 02, 2008 01:00 PM

Stefan,

A DATA belongs to an object. A CLASSDATA belongs to a Class.

For example:Imagine that you want to create a class TCar, and you want to know how many cars have been produced. Then you need a CLASSDATA nCars that will be a "shared" value from all Cars objects.

So everytime that a car is created, you do oCar:nCars++ and nCars is the same CLASSDATA shared from all Cars objects.

There are multiple cars, and just one nCars value.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
How to inherit from 7.12's rpreview class?
Posted: Thu Jan 03, 2008 05:36 AM

Thanks for the reply Antonio

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
How to inherit from 7.12's rpreview class?
Posted: Thu Jan 03, 2008 12:54 PM

Antonio,

Ok, I see.

Many thanks for the explanation

kind regards

Stefan

Continue the discussion