Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Generating & referencing unique object names
Message
 
 
To
21/06/1998 01:21:33
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00110322
Message ID:
00110374
Views:
21
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform