Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Generating & referencing unique object names
Message
 
 
À
21/06/1998 01:21:33
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00110322
Message ID:
00110374
Vues:
20
Bob,

If you store the name you can convert it to an object reference with eval:
this.cAddedObjectName = sys(2015)
local loObject
loObject = eval( this.cAddedObjectName )
with loObject
   .Height = 10
endwith
If you store object references as Kamal suggests, you need to make sure you get rid of the reference by setting it to .null. or your form won't properly destruct.

>Say I have a class that adds an object to a form. How do I generate and reference a unique object name?
>
>Example:
>If the object method does:
>THISFORM.AddObject("bob", "Line")
>then this might be bad because "bob" may already exist
>
>Do I do something like:
>THIS.cAddedObject = SYS(2015) && init my reference to added object
>THISFORM.AddObject(THIS.cAddedObject, "Line") && add the object
>
>And if this is right, then how do I de-reference it?
>THIS.cAddedObject.height = 10
>gives an error because THIS.cAddedObject is a string not an object.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform