Difference between revisions of "ADDPROPERTY()"

From Lianjapedia
Jump to: navigation, search
 
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Function to add a property to an existing object
 
Function to add a property to an existing object
 
  
 
==Syntax==
 
==Syntax==
 
ADDPROPERTY(<object-name> ,<expC>[,<exp>])
 
ADDPROPERTY(<object-name> ,<expC>[,<exp>])
 
  
 
==See Also==
 
==See Also==
[[ACLASS()]], [[AMEMBERS()]], [[CLASS]], [[CLASS - Methods]], [[CLASS - Parameters]], [[CLASS - Properties]], [[CLASS - Scoping]], [[COMPOBJ()]], [[CREATEOBJECT()]], [[DEFINE CLASS]], [[DISPLAY CLASSES]], [[DODEFAULT()]], [[FOREACH]], [[LIST CLASSES]], [[LOADOBJECT()]], [[METHOD]], [[NEWOBJECT()]], [[OBJECT()]], [[PRINT_HTML()]], [[PRINT_JSON()]], [[PRINT_R()]], [[PRINT_XML()]], [[REMOVEPROPERTY()]], [[REQUIRE_ONCE()]], [[SAVEOBJECT()]], [[SQL SELECT]], [[WITH]]
+
[[ACLASS()]], [[AMEMBERS()]], [[COMPOBJ()]], [[CREATEOBJECT()]], [[DEFINE CLASS]], [[DISPLAY CLASSES]], [[DODEFAULT()]], [[FOREACH]], [[LIST CLASSES]], [[LOADOBJECT()]], [[NEWOBJECT()]], [[OBJECT()]], [[PRINT_HTML()]], [[PRINT_JSON()]], [[PRINT_R()]], [[PRINT_XML()]], [[REMOVEPROPERTY()]], [[REQUIRE_ONCE()]], [[SAVEOBJECT()]], [[SQL SELECT]], [[WITH]]
 
+
  
 
==Description==
 
==Description==
Line 15: Line 12:
  
  
{| class="wikitable"
+
{| class="wikitable" width="100%"
!Parameter||Description
+
!width="20%"|Parameter||Description
 
|-
 
|-
 
|<object-name>||The name of the object.
 
|<object-name>||The name of the object.
Line 22: Line 19:
 
|<expC>||The name of the property to be added.
 
|<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).
+
|valign="top"|<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).
 
|-
 
|-
 
|}
 
|}
Line 35: Line 32:
  
 
Properties can be removed using the REMOVEPROPERTY() function or inbuilt ''removeproperty'' method.  
 
Properties can be removed using the REMOVEPROPERTY() function or inbuilt ''removeproperty'' method.  
 
  
 
==Example==
 
==Example==
Line 52: Line 48:
 
</code>
 
</code>
  
 
==Products==
 
Recital Server, Recital
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:Objects]]
 
[[Category:Objects]]
[[Category:Objects Functions]]
 

Latest revision as of 07:12, 4 February 2013

Purpose

Function to add a property to an existing object

Syntax

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

See Also

ACLASS(), AMEMBERS(), COMPOBJ(), CREATEOBJECT(), DEFINE CLASS, DISPLAY CLASSES, DODEFAULT(), FOREACH, LIST CLASSES, LOADOBJECT(), NEWOBJECT(), OBJECT(), PRINT_HTML(), PRINT_JSON(), PRINT_R(), PRINT_XML(), REMOVEPROPERTY(), REQUIRE_ONCE(), SAVEOBJECT(), SQL SELECT, 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")