Difference between revisions of "COMPOBJ()"

From Lianjapedia
Jump to: navigation, search
 
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Function to compare two objects
 
Function to compare two objects
 
  
 
==Syntax==
 
==Syntax==
 
COMPOBJ(<object-ref1>,<object-ref2>)
 
COMPOBJ(<object-ref1>,<object-ref2>)
 
  
 
==See Also==
 
==See Also==
[[ACLASS()]], [[ADDPROPERTY()]], [[AMEMBERS()]], [[CLASS]], [[CLASS - Methods]], [[CLASS - Parameters]], [[CLASS - Properties]], [[CLASS - Scoping]], [[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()]], [[ADDPROPERTY()]], [[AMEMBERS()]], [[CREATEOBJECT()]], [[DEFINE CLASS]], [[DIFFOBJ()]], [[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==
 
The COMPOBJ() function is used to compare the property name and property values of two objects.  The <object-ref1> is a reference to the first object to be compared and the <object-ref2> is a reference to the second object.  If the property names and values of the two objects are identical, COMPOBJ() will return .T. (true), if not it will return .F. (false).
 
The COMPOBJ() function is used to compare the property name and property values of two objects.  The <object-ref1> is a reference to the first object to be compared and the <object-ref2> is a reference to the second object.  If the property names and values of the two objects are identical, COMPOBJ() will return .T. (true), if not it will return .F. (false).
 
The built-in ''equals'' [[CLASS - Methods|class method]] can also be used to compare two objects.
 
 
  
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
class myclass1
+
define class myclass1 as custom
 
   property firstname
 
   property firstname
 
   property lastname
 
   property lastname
endclass
+
enddefine
 
+
class myclass2
+
define class myclass2 as custom
 
   property firstname
 
   property firstname
 
   property lastname
 
   property lastname
endclass
+
enddefine
 
+
 
class myclass3
+
define class myclass3 as custom
 
   property firstname
 
   property firstname
 
   property lastname
 
   property lastname
 
   property midinitial
 
   property midinitial
endclass
+
enddefine
 
+
 
o1 = new myclass1()
 
o1 = new myclass1()
 
o2 = new myclass2()
 
o2 = new myclass2()
 
o3 = new myclass3()
 
o3 = new myclass3()
 
+
 
o1.firstname = "John"
 
o1.firstname = "John"
 
o1.lastname = "Johnson"
 
o1.lastname = "Johnson"
 
+
 
o2.firstname = "Jack"
 
o2.firstname = "Jack"
 
o2.lastname = "Johnson"
 
o2.lastname = "Johnson"
 
+
 
o3.firstname = "John"
 
o3.firstname = "John"
 
o3.lastname = "Johnson"
 
o3.lastname = "Johnson"
 
+
 
? compobj(o1,o2)
 
? compobj(o1,o2)
 
// Returns .F. as firstname property has different values
 
// Returns .F. as firstname property has different values
 
+
 
o2.firstname = "John"
 
o2.firstname = "John"
 
? compobj(o1,o2)
 
? compobj(o1,o2)
 
// Returns .T. as properties and values identical
 
// Returns .T. as properties and values identical
 
+
 
? compobj(o1,o3)
 
? compobj(o1,o3)
// Returns .F. as although firstname and lastname property is identical, // o3 has a midinitial property and o1 does not
+
// Returns .F. as although firstname and lastname properties are identical,  
 +
// o3 has a midinitial property and o1 does not
 
</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 10:32, 20 August 2014

Purpose

Function to compare two objects

Syntax

COMPOBJ(<object-ref1>,<object-ref2>)

See Also

ACLASS(), ADDPROPERTY(), AMEMBERS(), CREATEOBJECT(), DEFINE CLASS, DIFFOBJ(), 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 COMPOBJ() function is used to compare the property name and property values of two objects. The <object-ref1> is a reference to the first object to be compared and the <object-ref2> is a reference to the second object. If the property names and values of the two objects are identical, COMPOBJ() will return .T. (true), if not it will return .F. (false).

Example

define class myclass1 as custom
  property firstname
  property lastname
enddefine
 
define class myclass2 as custom
  property firstname
  property lastname
enddefine
 
define class myclass3 as custom
  property firstname
  property lastname
  property midinitial
enddefine
 
o1 = new myclass1()
o2 = new myclass2()
o3 = new myclass3()
 
o1.firstname = "John"
o1.lastname = "Johnson"
 
o2.firstname = "Jack"
o2.lastname = "Johnson"
 
o3.firstname = "John"
o3.lastname = "Johnson"
 
? compobj(o1,o2)
// Returns .F. as firstname property has different values
 
o2.firstname = "John"
? compobj(o1,o2)
// Returns .T. as properties and values identical
 
? compobj(o1,o3)
// Returns .F. as although firstname and lastname properties are identical, 
// o3 has a midinitial property and o1 does not