Using class user objects

How you insert a nonvisual object

There are two ways to use a class user object when the user object is not autoinstantiating: you can create an instance of it in a script, or you can insert the user object in a window or user object using the Insert menu.

For more information on autoinstantiation, see “Using AutoInstantiate”.

The nonvisual object you insert can be a custom class user object or a standard class user object of most types.

StepsTo instantiate a class user object:

  1. In the window or user object in which you want to use the class user object, declare a variable of the user object type and create an instance of it using the CREATE statement. For example:

    // declared instance variable: 
    // n_myobject invo_myobject
    invo_myobject = CREATE n_myobject
    
  2. Use the user object’s properties and functions to do the required processing.

  3. When you have finished using the user object, destroy it using the DESTROY statement.

    If you select Autoinstantiate in the properties of the class user object, you cannot use the CREATE and DESTROY statements.

StepsTo insert a class user object:

  1. Open the window or user object in which you want to insert the class user object.

  2. Select Insert>Object from the menu bar.

  3. Select User Object (at the bottom of the list) and then select the class user object you want to insert.

    PowerBuilder inserts the selected class user object.

  4. Modify the properties and code the events of the nonvisual object as needed.

When the user object is created in an application, the nonvisual object it contains is created automatically. When the user object is destroyed, the nonvisual object is destroyed automatically.

Using the Non-Visual Object List view

You can use the same technique to insert standard class user objects. Since all class user objects are nonvisual, you cannot see them, but if you look at the Non-Visual Object List view, you see all the class user objects that exist in your user object.

Using the Non-Visual Object List view’s pop-up menu, you can display a class user object’s properties in the Properties view, display the Script view for the object to code its behavior, or delete the object.