> How to declare Abstruct Class in VFP?
There is no abstract class definition in VFP.
You could fake it by defining a class with this code in every method:
WAIT WINDOW prog() + ": code not yet defined"
Regards
Bernhard Sander
You can still put some code in the
abstract's init and dodefault(),
but in subclasses override the
return value to be .T.
That will solve the aspect, that abstract
classes should not be instanciable.
You can still drag&drop such a class
on a form or some other container class
visually, still if you don't override
it's init it will vanish at runtime.
o = CreateObject("abstract")
? VarType(o) && L = Logical, no object
o = CreateObject("concrete")
? Vartype(o) && Object = Instance of concrete class
Define Class Concrete as Abstract
Procedure Init()
DoDefault()
Return .T.
Endproc
EndDefine
Define Class Abstract as custom
Procedure Init()
Return .F.
EndProc
EndDefine
It's the easiest solution to not forget
to subclass such abstract classes, otherwise
you can easily have an abstract class
wrking concrete just by setting some
of it's properties or using the dynamics
of the VFP language like Macrosubstitution:
Define Class abstractButton As Commandbutton
procedure Click()
Eval(This.cClickcode)
Sorry, I hit submit too early:
Define Class abstractButton As Commandbutton
This.cClickCode = "ThisForm.SomeMethod()"
Procedure Click()
Eval(This.cClickCode)
Endproc
Enddefine
Now you could add this abstract button to
forms and then make it concrete by setting
the cClickCode appropriately.
This is not even using macro substitution,
eval is sufficient here (and faster).
Bye, Olaf.