Declaring a Namespace

You can specify a namespace for these PowerBuilder objects: custom and standard class objects, custom, standard, and external visual objects, windows, menus, structures, functions, interfaces, and enumerations.

Declare a namespace in the Declare Namespace\Usings window of the painter for any PowerBuilder object that supports namespace declarations.

You can also add using namespace directives in the Declare Namespace\Usings window. Using directives allow you to refer to a named type by its simple name rather than its compound name, which includes a namespace prefix.

  1. Open a painter for a PowerBuilder object.
  2. Select Declare from the drop-down list at the upper left of the painter, then select Namespace\Usings from the second drop-down list.
    Note: If it is available, you can click the Namespace\Usings tab at the bottom of the object painter instead of selecting from the drop-down lists.
  3. In the Namespace field, enter the namespace declaration.
    The namespace declaration applies only to the selected object and any objects that inherit from the selected object.
    Skip to step 5 if you do not want to include a Using directive in the source code for the current object.
  4. Click Add to open the Select Namespace dialog box and:
    1. Select an assembly or other item from the Assemblies list at the bottom of the dialog box.
    2. Select a namespace from the list of namespaces at the top of the dialog box, and click OK.
      The namespace you selected appears in the Using field of the object painter.
    3. Click Add again to include as many using namespace directives as you need.
  5. Save the object with its declared namespaces.
This example shows a namespace declaration as it would appear in source code after entering "sybase.pb.ns" for the namespace name and "dir1" and "dir2" for using namespace directives:
 
            namespace
            namespace sybase.pb.ns
            using dir1
            using dir2
            end namespace