* Author: Charlie Schreiner 05/05/1998 * * Put two objects into sync where object 1 is given object 2's values * Third parameter is optional to determine which properties we don't care about * or which properties we DO care about. * Forth parmeter is optional to determine whether the 3rd parmeter * excludes or includes properties. * Return .t. if objects were already in perfect harmony. * * Example: ObjSync(ObjectGettingSet, ; * ObjectWithValues, ; * ["HelpContextID","Top"], .F. * Notice the brackets to contain the exclude/include strings. LPARAMETERS Obj1, Obj2, String, Include LOCAL PropertyNumber IF NOT TYPE("m.Include") = "L" Include = .F. ENDIF IF TYPE("m.String") = "C" String = UPPER(m.String) ELSE IF NOT m.Include String = ["HELPCONTEXTID"] ENDIF ENDIF LOCAL ARRAY aObj1[1] LOCAL ARRAY aObj2[1] LOCAL RetVal, CheckIt RetVal = .T. AMEMBERS(aObj1, m.Obj1) && Put the properties of object 1 into an array. AMEMBERS(aObj2, m.Obj2) && Put the properties of object 2 into an array. SET EXACT ON FOR PropertyNumber = 1 TO ALEN(aObj2,1) PropertyName = aObj2[m.PropertyNumber] * First try to find Object2's property in Object1. IF ASCAN(aObj1,m.PropertyName) > 0 ; AND NOT PEMSTATUS(m.Obj1,m.PropertyName,1) * Found it and not readonly CheckIt = .F. IF m.Include IF NOT EMPTY(m.String) CheckIt = INLIST(UPPER(m.PropertyName), &String.) ENDIF ELSE CheckIt = NOT INLIST(UPPER(m.PropertyName),&String.) ENDIF IF m.CheckIt ** If it's defined, see if they are equal. IF NOT EVAL("m.Obj2." + m.PropertyName) = EVAL("m.Obj1." + m.PropertyName) ; AND NOT ISNULL(EVAL("Obj2." + m.PropertyName)) * Added the ISNULL check 7/26/1999 CLS. STORE EVAL("Obj2." + m.PropertyName) TO ("m.Obj1." + m.PropertyName) RetVal = .F. && Mismatch was found. ENDIF ENDIF ENDIF ENDFOR SET EXACT OFF RETURN m.RetVal