Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a copy of the existing class
Message
 
 
To
09/03/2005 23:47:24
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
00994181
Message ID:
00994409
Views:
17
Well, I tried to implement the plan A. I get the latest version from VSS, but now I'm having the same problem as I had before. I had to try another plan.

>>>How about using the class browser and opening the class. Select the view class code and select the code for a copy paste.
>>
>>But I need to re-create the properties (with their comments) and methods (with their comments) I added to the class. I don't see how Class Browser is going to help me. I would see all methods and properties, but I still have to add them somehow.
>
>Ok, here's what I did for this before I started writing builders. Actually, this is a way of lightweight builder.
>
>Edit both classes at the same time. Use aselobj() to get references to each, say oOld and oNew. Then have two routines:
>
>
procedure CopyProperty(o1, o2, cProperty)
>o2.addproperty(cProperty, eval("o1."+cproperty))
>
>procedure copyMethod(o1, o2, cMethod)
>o2.writemethod(cMethod, o1.readmethod(cmethod), .t.)
>
>Now just
>
>copyproperty(oOld, oNew, "backcolor")
>copyproperty(oOld, oNew, "forecolor")
>copyproperty(oOld, oNew, "disabledbackcolor")
>...etc etc, any properties you may want to copy. Similarly for code:
>
>copymethod(oOld, oNew, "YourCustomMethod")
>copymethod(oOld, oNew, "click")
>
>You may also want a copy member method - if you have December FoxTalk2.0, you can take it from my article there, it's part of the sample code - you only need to write about four lines of code, to extract classlib and class from the member to copy, and then oNew.newobject() it.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform