Defining an Interface

An interface specifies the members of a class that must be supplied by any class that implements the interface. In PowerBuilder .NET, you can create interfaces from the New dialog box.

Because PowerScript has no concept of abstract classes, all methods, properties, events, and indexers defined in PowerBuilder .NET interfaces must be implemented by a PowerBuilder object class.

  1. Select File > New > PBObject > Interface and:
    • Click Next to open and scroll through the wizard.

      Provide a name for the interface and select the library where you want to save the interface. On the next wizard page, you can select a namespace and using namespace directives for the new interface, and you can declare additional interfaces that must be implemented by objects implementing the new interface.

    • Click Finish to open the Interface painter.

      If you click Finish without providing a name for the interface, the Interface painter displays Untitled as the temporary name for the interface.

  2. Make sure the interface name (or Untitled) appears in the drop-down list at the upper left of the Interface painter.
  3. From the second drop-down list at the top of the Interface painter, select New Event to add events to the interface, and enter values and parameters for each new event.
  4. From the first drop-down list, select the appropriate option to add functions, indexers, or properties to the interface, or to declare a namespace or another interface.

    A new painter window opens for the item you select. You may need to select an appropriate item (New Function, New Indexer, New Property, Namespace/Usings, or Interfaces) from the second drop-down list in the painter.

    Add as many functions, indexers, properties, or declarations as required for the interface.

  5. Save the interface.
    If you did not provide a name for the interface in the wizard, the Save Interface dialog box prompts you for an interface name and the library in which to save it.
Related concepts
About the Interface Painter