Using the extension in PowerBuilder

PowerBuilder Native Interface

Using the extension in PowerBuilder

  1. Copy the PBX (or DLL) file to a directory on your application's path.

  2. In PowerBuilder, create a new workspace.

  3. On the Target page of the New dialog box, select the Application icon to create a new target, library, and application object.

  4. In the System Tree, expand the new target, right-click the library, and select Import PB Extension from the pop-up menu.

    pbext01.gif
  5. Navigate to the location of the pbadd.pbx file and click Open.

  1. Create a new window called w_add, and add three single-line edit boxes and a command button to it.

  2. Declare an instance variable called mypbadd for the pbadd native class, and then add this script to the button's Clicked event:

    TRY
       mypbadd = CREATE pbadd
       sle_3.text = string (mypbadd.f_add( &
          integer(sle_1.text), integer(sle_2.text)))
    CATCH (runtimeerror re)
       MessageBox("Error", &
          "pbadd native class could not be created: " + &
          re.getmessage() )
    END TRY

    addints1.gif
  3. Add open(w_add)to the application's Open event.

  4. Run the application.

    The application runs just as it would if you had created a custom class user object in PowerBuilder with an f_add function. If PowerBuilder cannot find pbadd.pbx, the runtime error in the Clicked event script will be triggered and caught. Put pbadd.pbx in the same directory as the executable or the PowerBuilder runtime DLLs to make sure it can be found.