This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v20 R7
OB Instance of

OB Instance of 


 

OB Instance of ( object ; class ) -> Function result 
Parameter Type   Description
object  Object in Object whose class is to be tested
class  Object in Class to test belongship
Function result  Boolean in True if object belongs to the specified class or a child class, and false otherwise

The OB Instance of command returns true if object belongs to class or to one of its child classes, and false otherwise.

If class is not a valid Class object, the error -10745 is returned.

Note: Each time a class's sources are modified, a new Class object is generated. As previously instantiated objects do not belong to the new class, OB Instance of will return false if you pass a Class object other than the one used for instantiation.

Example  

You created the Polygon class:

  //Class: Polygon
 Class constructor
 C_LONGINT($1;$2)
 This.area:=$1*$2

Then, in a method, you can write:

 C_OBJECT($poly)
 C_BOOLEAN($instance)
 
 $poly:=cs.Polygon.new(4;3)
 
 $instance:=OB Instance of($poly;cs.Polygon)
  // true
 
 $instance:=OB Instance of($poly;4D.Object)
  // true 
 
 $instance:=OB Instance of($poly;cs.Circle)
  // false



See also 

OB Class

 
PROPERTIES 

Product: 4D
Theme: Objects (Language)
Number: 1731

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v18 R3

 
ARTICLE USAGE

4D Language Reference ( 4D v20 R7)