The object() function returns an object handle for existing objects. An object handle is a distinguished data type in ASL that represents a model class name and an object name. The syntax is one of the following:

  • <objectRef> = object([<classname>,] <objectname>);

    The name of the instance must be unique, therefore, the class name is optional.

  • <objectRef> = object(<objhandle>);

    There are three ways to obtain a handle for an existing object:

  • If you specify a class name and an object name, then the object() function returns the object handle for the specified object. ASL stores that information as <class>::<name>.

  • If you specify an object handle (objhandle), then the object() function returns the object handle unchanged.

  • If you specify an object name only, then the object() function returns the handle object and assumes the object name and the class name, MR_Object.

    You can also create an object handle for future use for an object that does not exist.

    For example:

    objref = object();
    

    The following script retrieves the names of all instances of the class “Card” and stores them in a list. A foreach loop cycles through the list and adds each object, including its class, to a different list. The script prints both lists.

    The lists demonstrate the difference between the getInstances() function and the object() function. The getInstances() function returns only the name of the object. The object() function returns the object handle for the object and ASL stores that information as <class>::<name>. The section “Listing instances” on page 105 describes the getInstances() function.

    ASL Script (handle_obj.asl):
    y = list();
    START {
     ..eol
    }
    do {
     x = getInstances("Card");
     print(x);
    
     foreach mem (x)
      {y += object("Card",mem);
      }
    
     print(y);
    }
    Input:
    none
    Output:
    $ sm_adapter --server=JS1 handle_obj.asl
    { CARD0, CARD1, CARD2 }
    { Card::CARD0, Card::CARD1, Card::CARD2 }