Finding and executing functions and events

PowerBuilder looks for a matching function or event based on its name and its argument list. PowerBuilder can make a match between compatible datatypes (such as all the numeric types). The match does not have to be exact. PowerBuilder ranks compatible datatypes to quantify how closely one datatype matches another.

A major difference between functions and events is how PowerBuilder looks for them.

Finding functions

When calling a function, PowerBuilder searches until it finds a matching function and executes it -- the search ends. Using functions with the same name but different arguments is called function overloading. For more information, see Overloading, overriding, and extending functions and events.

Unqualified function names

If you do not qualify a function name with an object, PowerBuilder searches for the function and executes the first one it finds that matches the name and arguments. It searches for a match in the following order:

  1. A global external function.

  2. A global function.

  3. An object function and local external function. If the object is a descendant, PowerBuilder searches upward through the ancestor hierarchy to find a match for the function prototype.

  4. A system function.

DataWindow expression functions

The functions that you use in the DataWindow painter in expressions for computed fields, filters, validation rules, and graphed data cannot be overridden. For example, if you create a global function called Today, it is used instead of the PowerScript system function Today, but it is not used instead of the DataWindow expression function Today.

Qualified function names

You can qualify an object function using dot notation to ensure that the object function is found, not a global function of the same name. With a qualified name, the search for a matching function involves the ancestor hierarchy only (item 3 in the search list above), as shown in the following examples of function calls:

dw_1.Update( )

When PowerBuilder searches the ancestor hierarchy for a function, you can specify that you want to call an ancestor function instead of a matching descendant function.

For the syntax for calling ancestor functions, see Calling functions and events in an object's ancestor.

Finding events

PowerBuilder events in descendant objects are, by default, extensions of ancestor events. PowerBuilder searches for events in the object's ancestor hierarchy until it gets to the top ancestor or finds an event that overrides its ancestor. Then it begins executing the events, from the ancestor event down to the descendant event.

Finding functions versus events

The following illustration shows the difference between searching for events and searching for functions: