Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Short Question Please Help
Message
From
01/06/2001 04:18:05
James Beerbower
James Beerbower Enterprises
Hochheim Am Main, Germany
 
 
To
01/06/2001 04:16:17
James Beerbower
James Beerbower Enterprises
Hochheim Am Main, Germany
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00513608
Message ID:
00513616
Views:
17
ps. good luck and we take no responsibility if there should be a bug (I just coded it) or if someone should consider the coding ugly <g>

>There are no doubt other approaches but this should work...
>
>function ocopy(toFrom,toTo)
>	local laFromProperties,lcPropertyName,lcCommand
>	*
>	* The idea is to copy all of the user defined properties from
>	* one object to another.  It will overwrite system created properties that
>	* are user created properties in toFrom: e.g.
>	* A copied to B where B is say a listbox and A is a custom object.  Background
>	* color is a VFP property in B but a user created copy in A.  This function would
>	* copy the value.
>
>	if vartype(toFrom)#"O" or isnull(toFrom)
>		* error
>		return .f.
>	endif
>	if vartype(toTo)#"O" or isnull(toTo)
>		* error
>		return .f.
>	endif
> 	dimension laFromProperties(1)
>	=amembers(laFromProperties,toFrom)	
>
>	*
>	* loop through toFrom looking for developer defined properties
>	* copy the values to toTo	
>	for each lcPropertyName in laFromProperties
>		if !pemstatus(toFrom,lcPropertyName,4) && VFP defined
>	   		loop
>		endif
>		if pemstatus(toTo,lcPropertyName,5)
>			lcCommand = "toTo."+lcPropertyName + " = toFrom." + lcPropertyName
>			&lcCommand
>		endif
>	endfor	
>	
>	return .t.	
>endfunc
>
>>Hi all,
>>
>>for example:
>>define class MyObject as container
>>  A=""
>>  B=""
>>  C=""
>>enddefine
>>
>>
>>If I have two object Box1 and Box2 define as MyObject, and want to copy the data in Box1 to Box2, do I need to do it like this
>>Box2.A=Box1.A
>>Box2.B=Box1.B
>>Box2.C=Box1.C
>>
>>
>>or there is another easier method? I have tried Box2=Box1 but it say syntax error..
>>
>>Thanks in advance!
James Beerbower
James Beerbower Enterprises
Frankfurt, Deutschland
Previous
Reply
Map
View

Click here to load this message in the networking platform