Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Copying an Object - avoiding single object references
Message
De
03/05/2000 15:06:43
Charlie Schreiner
Myers and Stauffer Consulting
Topeka, Kansas, États-Unis
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00365455
Message ID:
00365737
Vues:
22
>Anybody have any ideas?

Hi Rick,
This code saves all properties and any object's properties.
Example _SCREEN.AddObject('MyObject','TextBox')
oMirror = CREATEOBJECT("MirrorObj")
oMirror.Mirror(_SCREEN)
* Saves the properties of the _SCREEN and the textbox in the screen.
* Each object is saved into an array that is a property of this
* class. Of course I just did this so its not tested. (It does run!)
DEFINE CLASS MirrorObj AS RELATION
  DECLARE aMirror[1,2]

  **********************************
  PROCEDURE INIT
    THIS.aMirror = .NULL.
  ENDPROC

  **********************************
  PROCEDURE RELEASE
    RELEASE THIS
  ENDPROC

  **********************************
  PROCEDURE Mirror(Obj)
    LOCAL ARRY aItems[1,2]
    LOCAL TotalItems, ArrayRows
    TotalItems = AMEMBERS(aItems, m.Obj, 1)
    IF m.TotalItems > 0
      FOR x = 1 TO ALEN(aItems,1)
        IF INLIST(aItems[x,2],"Property", "Object") ;
            AND NOT TYPE("Obj." + aItems[x,1]) = "U" ;
            AND NOT aItems[x,1] == "Parent"

                * We have something to save.
	        IF ISNULL(THIS.aMirror[1,1])
	          ArrayRows = ALEN(THIS.aMirror,1) + 1
	          DIMENSION THIS.aMirror[m.ArrayRows, 2]
	        ENDIF
	        DO CASE
	        CASE aItems[x,2] = "Property"
           * Save the property name
           THIS.aMirror[m.ArrayRows,1] = aItems[x,1]
           * Save the value
           THIS.aMirror[m.ArrayRows,2] = EVALUATE("Obj." + aItems[x,1])
        CASE aItems[x,2] = "Object"
          * Save another object.
          THIS.aMirror[m.ArrayRows,1] = EVALUATE("Obj." + aItems[x,1] + ".Name")
          THIS.aMirror[m.ArrayRows,2] ;
            = CREATEOBJECT('MirrorObj')
          THIS.aMirror[m.ArrayRows,2].Mirror(EVALUATE("Obj." + aItems[x,1]))
        ENDCASE
      ENDIF
    ENDFOR
  ENDIF
  RETURN

ENDDEFINE
Charlie
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform