Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Added methods and properties to the wrong class level
Message
From
24/01/2009 15:44:27
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01376700
Message ID:
01376767
Views:
18
This message has been marked as the solution to the initial question of the thread.
>Hi all
>
>Is there a hack that I can do do transfer PEMs from a class to another as I have added stuff to the wrong level of the class hierarchy and redoing is possible but if I can hack stuff to the right class that will be better.
>
>Please suggest.

Clipboard suggested.

Seriously, unless there's ton of PEMs that you want to move up, the best you can do is to just create them in the parent class, then copy their definition from the subclass. Going in the other direction would just require moving them from parent and in the end removing these PEMs from parent (but then you need to check the child's Reserved3 or which memo was it where the extra PEMs are listed - make sure they are).

A hack I think may work would involve opening both classes at the same time, which just wouldn't work because one is parent to the other. But then we only need to copy things from one to another - which means we can open a copy of the child, which would inherit from a copy of the parent (and the rest of upwards hierarchy), easily done if these copies are in a discardable copy of the class lib directory.

Then you'd have a reference to the parent and child as edited objects, builder style, and then
* in meta code
* oDad, oChild are aSelObj() references to classes we're editing
n=aMembers(aPem, oChild, "UC") && own or changed
for i=1 to n
   do case
      case ThisIsAProperty
         oDad.addproperty(aPem[i,2], getpem(oChild, aPem[i,2]))
      case ThisIsCode
         oDad.WriteMethod(aPem[i,2], oChild.ReadMethod(aPem[i,2]), .t.)
      case ThisIsAMemberObject
         *-- recurse into the object.
   endcase
endfor
Close, save, kick yourself in the head if you didn't backup first.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform