Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copy methods and properties from one form to another
Message
From
16/03/2002 01:18:17
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00633623
Message ID:
00633700
Views:
27
This message has been marked as a message which has helped to the initial question of the thread.
>Hi everybody,
>
>I have a form which is based on class which includes pageframe. This form has bunch of own properties and methods.
>
>I want to create another form based on another class (which doesn't have pageframe as a member), but this form should have all properties and methods as the first form. (E.g I want to re-design this form using another classlibrary).
>
>I put pageframe on the form, set pages to be 4, as on the first form, but now I'm thinking, how can I automate the process of copying properties and methods.
>
>Do you have ideas?

Open them both in editor. Select the first one. In command window,

aselobj(aa)
o1=aa(1)
Do the same with the other object, to get o2 as a reference to the second object. Then run this:

do cprop with "{property name here}"
do cmeth with "{method name here}"

Here's the two progs:
* cprop.prg
lparameters cProp

cNewVal=evaluate("o1."+cProp)
if type("cNewVal")#"U" or isnull(cNewVal)
	if PEMSTATUS(o2,cProp,5)
		store cNewVal to ("o2."+cProp)
	else
		o2.addproperty(cProp, cNewVal)
	endif
else
	=alert(cProp+" is not such a good property of "+o1.name)
endif

*cmeth.prg
LPARAMETERS cMethod
o2.writemethod(cMethod, o1.ReadMethod(cMethod),.t.)
So yes, you still have to type the names of each property and method - I took to programmers of 1st kind here, and didn't write proper scanner which would go down amembers() of o1 and call these two routines for each property and method which had non-default values. Eto domashnyaya rabota dlya tebya :) Recursion would be optional.

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