Difference between revisions of "ADDPROPERTY()"

From Recital Documentation Wiki
Jump to: navigation, search
Line 12: Line 12:
  
 
==Description==
 
==Description==
The Visual FoxPro compatible ADDPROPERTY() function is used to add a property to an existing object.  It returns .T. (True) if the property was successfully added and .F. (False) otherwise.
+
The ADDPROPERTY() function is used to add a property to an existing object.  It returns .T. (True) if the property was successfully added and .F. (False) otherwise.
  
  
Line 27: Line 27:
  
  
All classes have an inbuilt ADDPROPERTY 'factory method'.  This can be used as an alternative to the ADDPROPERTY() function to add properties to an object at runtime.
+
All classes have an inbuilt ''addproperty'' method.  This can be used as an alternative to the ADDPROPERTY() function to add properties to an object at runtime.
  
 
<object-name>.addproperty(<expC>,<exp>)
 
<object-name>.addproperty(<expC>,<exp>)
Line 34: Line 34:
  
  
Properties can be removed using the REMOVEPROPERTY() function or inbuilt REMOVEPROPERTY 'factory method'.  
+
Properties can be removed using the REMOVEPROPERTY() function or inbuilt ''removeproperty'' method.  
  
  

Revision as of 10:40, 14 December 2009

Purpose

Function to add a property to an existing object


Syntax

ADDPROPERTY(<object-name> ,<expC>[,<exp>])


See Also

ACLASS(), AMEMBERS(), CLASS, COMPOBJ(), CREATEOBJECT(), DEFINE CLASS, DODEFAULT(), METHOD, NEWOBJECT(), REMOVEPROPERTY(), SET CLASSLIBRARY, TOSTRING(), WITH


Description

The ADDPROPERTY() function is used to add a property to an existing object. It returns .T. (True) if the property was successfully added and .F. (False) otherwise.


Parameter Description
<object-name> The name of the object.
<expC> The name of the property to be added.
<exp> The value to assign to the property being added. This is optional: if omitted and the property being added already exists, the property value is unchanged, if omitted and the property is new, the value is initialized to .F. (False).


All classes have an inbuilt addproperty method. This can be used as an alternative to the ADDPROPERTY() function to add properties to an object at runtime.

<object-name>.addproperty(<expC>,<exp>)

Note: the <exp> value is required.


Properties can be removed using the REMOVEPROPERTY() function or inbuilt removeproperty method.


Example

define class myclass as custom
  myprop = "Hello World"
enddefine
 
myobject = createobject("myclass")
Messagebox(myobject.myprop)
addproperty(myobject, "myprop2", "goodbye")
// Or: myobject.addproperty("myprop2", "goodbye")
Messagebox(myobject.myprop2)
removeproperty(myobject, "myprop2")
// Or: myobject.removeproperty("myprop2")


Products

Recital Server, Recital