Loading...
 

Inherited

Inherited

Inherited, Inherited(access expression)

Parameter: optionally an access printout

Stack
Stack Position Description
Stack(In) Top an object (with the classID1)
Top 1 Identifier of a class classID2
Stack(Out) Top Distance in the class hierarchy or 0 if no is-a relationship exists.

The statement tests whether either the object is derived from Stack-Top (if no parameter is specified) or whether the object reached by it via access expression is derived from the class specified on Stack-Top-1 (classID1 is a classID2). The result is the distance between the class of the specified object and the specified class, where

  • 0 means that the class with ClassID1 does not inherit from the class with ClassID2,
  • 1 means that ClassID1 equals ClassID2,
  • any value n > 1 means that the class with ClassID1 inherits from the class with ClassID2 and (n-2) other classes are in between in the inheritance hierarchy.

If the object is a wrapper or similar (CX_DESCRIPTIVE_REF, CX_FCONDITION or derived) and no type of inheritance hierarchy is specified as class identifier, the Inherited command additionally tests whether the wrapped object inherits from the specified class.

Code example:

Var(value) 5€ -> value
CX_VALUE value Inherited // => 1, as CX_VALUE is a CX_VALUE

Var(value) 5€ -> value
CX_NUMERIC value Inherited // => 2, as CX_VALUE is directly inherited from CX_NUMERIC

Var(value) 5€ -> value
CX_CLASS value Inherited // => 4, as CX_VALUE is inherited from CX_NUMERIC, CX_AMOUNT, CX_CLASS

Var(value) 5€ -> value
CX_ACCOUNT value Inherited // => 0, as CX_VALUE is not inherited from CX_ACCOUNT

parameters: -

Stack
Stack Position Description
Stack(In) Top Identifier of a class classID1
Top 1 Identifier of a class classID2
Stack(Out) Top TRUE or FALSE

The statement tests whether an object of class classID1 is derived from the class designated by classID2.
In other words: the result is TRUE if "classID2 is a classID1".

Attention: The order of the parameters is reversed here compared to the call with an object.
CX_VALUE obj InheritedCX_VALUE obj Type Swap Inherited

No parameter may be specified here.

Code example:

CX_VALUE CX_VALUE Inherited // => 1, as CX_VALUE is a CX_VALUE

CX_VALUE CX_NUMERIC Inherited // => 2, as CX_VALUE is directly inherited from CX_NUMERIC

CX_VALUE CX_CLASS Inherited // => 4, as CX_VALUE is inherited from CX_NUMERIC, CX_AMOUNT, CX_CLASS

CX_VALUE CX_ACCOUNT Inherited // => 0, as CX_VALUE is not inherited from CX_ACCOUNT