>>>x=createobject('form')
>>>y=createobject(x.class)
>>
>>It only creates an object of the same class, not a copy of the initial object.
>
>Try this.
>John Burton
>
>FUNCTION CopyObjectProperties
>LPARAMETERS oSource, oTarget
>LOCAL aProperties[1], i, p1
>DO ListCustomProperties WITH oSource, aProperties
>FOR i = 1 TO ALEN(aProperties)
>p1 = aProperties[i]
>IF TYPE('oTarget.&p1[1]')='U'
>* not an array
>oTarget.&p1 = oSource.&p1
>ELSE
>= ACOPY(oSource.&p1, oTarget.&p1)
>ENDIF
>ENDFOR
>ENDFUNC
>
>PROCEDURE ListCustomProperties
>LPARAMETER oObject, aArr
>LOCAL a1[1], a2[1], ch, n
>=AMEMBERS(a1, oObject, 1)
>=AMEMBERS(a2, oObject.BaseClass)
>DIMENSION aArr(ALEN(a1))
>n = 0
>FOR i = 1 TO ALEN(a1, 1)
>ch = a1[i, 1]
>IF a1[i,2]='Property' AND 0=ASCAN(a2, ch)
>n = n + 1
>aArr[n] = ch
>ENDIF
>ENDFOR
>DIMENSION aArr[n]
>ENDPROC
There are a few more things you need to check before doing something like this. Here is a snippet from a routine I ahve that copies properties from one object to another:
FOR i = 1 TO ALEN(aProps)
IF !ALLTRIM(UPPER(aProps(i)))$"CLASS:PARENTCLASS:BASECLASS:NAME"
uVal = GETPEM(o1,aProps(i))
IF PEMSTATUS(o2,aProps(i),5)
IF !PEMSTATUS(o2,aProps(i),1)
IF !PEMSTATUS(o2,aProps(i),2)
o2.WriteExpression(aProps(i), uVal)
ENDIF
ENDIF
ENDIF
ENDIF
ENDFOR
Erik Moore
Clientelligence