I've inherited an app with numerous classes defined in PRGs. I need
minor variations on a few and since there is so much code I want to
reuse, not to mention inheritance being such a big plus, it feels like
it would
defeat the purpose to recreate them.

Is there a way to subclass these? If so can you offer suggestions or
resources on how to do so? I can't seem to find any info when
searching the web.


Thanks,
Jim

Re: Subclass programatically defined classes by Denis

Denis
Thu Jan 04 08:47:15 CST 2007

Hi
Take a look at the prgtovcx program can be downloaded here
http://leafe.com/dls/vfp
Have not used it myself but have some class that have been created by
another programmer using this program. You can then easily subclass from the
visual class.

hth

Have
"Jim" <DontEvenBother@hotmail.com> wrote in message
news:1167921542.623728.171240@s80g2000cwa.googlegroups.com...
> I've inherited an app with numerous classes defined in PRGs. I need
> minor variations on a few and since there is so much code I want to
> reuse, not to mention inheritance being such a big plus, it feels like
> it would
> defeat the purpose to recreate them.
>
> Is there a way to subclass these? If so can you offer suggestions or
> resources on how to do so? I can't seem to find any info when
> searching the web.
>
>
> Thanks,
> Jim
>



Re: Subclass programatically defined classes by Bernhard

Bernhard
Thu Jan 04 08:56:18 CST 2007

Hi Jim,

> I've inherited an app with numerous classes defined in PRGs. I need
> minor variations on a few and since there is so much code I want to
> reuse, not to mention inheritance being such a big plus, it feels like
> it would
> defeat the purpose to recreate them.
>
> Is there a way to subclass these? If so can you offer suggestions or
> resources on how to do so? I can't seem to find any info when
> searching the web.

Maybe hit F1 in VFP IDE ;-)

It is very easy to subclass a class which is defined in a prg.
But you cannot use the designers.

In another prg, just write:
DEFINE CLASS subclass AS superclass OF superclasslib.prg
* your additions here:
* existingProperty = OtherValue
* NewProperty = value
* procedure OverloadExisitingMethod(using, same, parameters)
* endproc
* procedure NewMethod
* endproc
ENDDEFINE

In a prg class definition, you could inherit from a vcx class:
DEFINE subclass AS vcxclass OF classlibrary.vcx
...
ENDDEFINE

Regards
Bernhard Sander

Re: Subclass programatically defined classes by Jim

Jim
Thu Jan 04 09:22:15 CST 2007

Thanks Bernhard.

I guess I gave up too easily as I had previously spent a several days
trying to define new classes in PRGs based on the existing ones to no
avail and assumed after countless failures that it couldn't be done
that way. A few more experiments following your suggestion and I now
have a working example. ...which makes me wonder what in the world I
was doing back in Oct, but I'm happy to be on the right path. Thanks
again!

p.s. I removed the F1 key from my computer. It was either that or
remove more hair from my head from trying to find anything useful
(besides basic syntax) in the VFP help file. What can I say? Vanity
won out. <g>

Bernhard Sander wrote:
> Hi Jim,
>
> > I've inherited an app with numerous classes defined in PRGs. I need
> > minor variations on a few and since there is so much code I want to
> > reuse, not to mention inheritance being such a big plus, it feels like
> > it would
> > defeat the purpose to recreate them.
> >
> > Is there a way to subclass these? If so can you offer suggestions or
> > resources on how to do so? I can't seem to find any info when
> > searching the web.
>
> Maybe hit F1 in VFP IDE ;-)
>
> It is very easy to subclass a class which is defined in a prg.
> But you cannot use the designers.
>
> In another prg, just write:
> DEFINE CLASS subclass AS superclass OF superclasslib.prg
> * your additions here:
> * existingProperty = OtherValue
> * NewProperty = value
> * procedure OverloadExisitingMethod(using, same, parameters)
> * endproc
> * procedure NewMethod
> * endproc
> ENDDEFINE
>
> In a prg class definition, you could inherit from a vcx class:
> DEFINE subclass AS vcxclass OF classlibrary.vcx
> ...
> ENDDEFINE
>
> Regards
> Bernhard Sander