The is() function tests whether an object is a member of a relationship. The syntax is as follows:
is(<objectRef>-><Relationship>,<objectRef2>)
The <relationship> used in the is() function must be a valid relationship for the object or an error occurs. If <objectRef2> is related to <objectRef> by <Relationship>, the function returns TRUE. Otherwise, the function returns FALSE.
This script tests objects of the class Port to see if they are related to CARD2. The script gets the list of ports by using the class Port. When the ports are printed, the class that is printed is MR_Object, which is the parent class of the Port and Card classes. The MR_Object class appears because a class is not specified for the object() function.
ASL Script (relation_obj.asl): START { ..eol } do { cardObj = object("CARD2"); x = getInstances("Port"); foreach mem (x) { portObj = object(mem); if (is(cardObj->ComposedOf,portObj)) {print(portObj." is related to ".cardObj); } } } Input: none Output: $ sm_adapter --server=JS1 relation_obj.asl MR_Object::PORT20 is related to MR_Object::CARD2 MR_Object::PORT21 is related to MR_Object::CARD2 MR_Object::PORT22 is related to MR_Object::CARD2 MR_Object::PORT23 is related to MR_Object::CARD2 MR_Object::PORT24 is related to MR_Object::CARD2 MR_Object::PORT25 is related to MR_Object::CARD2 $