Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to add property to an empty object?
Message
From
29/04/2021 01:10:28
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
General information
Forum:
Visual FoxPro
Category:
Contracts, agreements and general business
Miscellaneous
Thread ID:
01680052
Message ID:
01680053
Views:
62
>Hi,
>
>I want to create an empty object as a property of another object. Then add a couple of properties to the empty object.
>Here is what I know how to do:
>
>toObject.AddProperty("oTableInfo", "Empty")
>
>
>Then, I need to add a property 'config_xml' to the oTableInfo and set it to empty string (''). I tried the following:
>
>AddProperty( toObject.oTableInfo, "config_xml", "")
>
>
>But the above gives a run-time error. What am I missing?
>
>TIA
>
>UPDATE: This works:
>
>	LOCAL oTableInfo
>	oTableInfo = CREATEOBJECT("empty")
>	ADDPROPERTY( oTableInfo, "config_xml", "" )
>    toObject.AddProperty("oTableInfo", oTableInfo)
>
>
>Let me know if the above works but wrong.

TL;DR:
Your example should work as long as toObject is not empty object.
This might be more secure:
LOCAL oTableInfo
oTableInfo = CREATEOBJECT("empty")
ADDPROPERTY( oTableInfo, "config_xml", "" )
ADDPROPERTY( toObject, "oTableInfo", oTableInfo)
Long:
This is the syntax for empty object:
LOCAL oTableInfo
oTableInfo = CREATEOBJECT("empty")
ADDPROPERTY( oTableInfo, "config_xml", "" )
This is because the empty object is empty - it exposes no methods or events - so there is no .AddProperty() method and you must use the AddProperty() function.

Any other object works both ways
LOCAL oTableInfo
oTableInfo = CREATEOBJECT("custom")
ADDPROPERTY( oTableInfo, "config_xml", "" )
oTableInfo.AddProperty("SomeProp", vSomeValue)
Conclusio, long code short:
ADDPROPERTY( toObject, "oTableInfo",  CREATEOBJECT("empty") )
ADDPROPERTY( toObject.oTableInfo, "config_xml", "" )
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform