Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

Create a new user function and user event – PB Docs 2022 – PowerBuilder Library

Create a new user function and user event – PB Docs 2022

Create
a new user function and user event

Where you are

Add a new sheet window
to the existing application

Create user-defined
exception objects

> Create a new
user function and user event

Call the methods and
catch the exceptions

Run the
application

Now you add a function that you invoke from the Percentage command
button’s Clicked event and an event that is triggered when the focus is
changed from the drop-down list box on the w_cust_pct window. The function
calculates the percentage of customers living in a particular state. The
event processes the current value of the drop-down list box control to
make sure it is two characters in length (for the state code).

  1. Open w_cust_pct in the Window painter if it is not already
    open.

    Select (Functions) in the first list box in the Script
    view.

    The Script view displays the Prototype window. The first
    drop-down list box in the Script view displays (Functions) and the
    second drop-down list box displays (New Function).

  2. Select decimal for the Return Type and type uf_percentage for
    Function Name.

  3. Select integer for the Argument Type and type ai_custbystate for
    the Argument Name.

    You will add a second argument in the next step.

  4. Right-click anywhere in the Prototype window and select Add
    Parameter from the pop-up menu.

  5. Select integer for the second Argument Type and type
    ai_totalcust for the second Argument Name.

  6. Type exc_no_rows,exc_low_number in the Throws box.

  7. Enter the following script for the new function:

    Later in this tutorial, you will call the uf_percentage function
    from the Clicked event on the command button, passing in two integers
    and processing the return value.

    You now add a user event for the drop-down list box that throws
    the exc_bad_entry exception object when a user-entered state code is
    not exactly two characters in length.

  8. Select ddlb_state in the first drop-down list box of the Script
    view and select (New Event) in the second drop-down list box.

  9. Select integer for Return Type and type ue_modified for Event
    Name.

    Select string for Argument Type and type as_statecode for
    Argument Name.

    Type exc_bad_entry in the Throws box or drag it from the System
    Tree to the Throws box.

    Note that the Event ID is (None). You do not select an Event ID
    for the ue_modified event. If you selected an Event ID, you could not
    enter user-defined exception objects in the event Throws
    clause.

  10. Enter the following script for the new ue_modified event:

    Next you call the ue_modified event and the uf_percentage
    function, and catch the exceptions thrown by these methods.


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x