Resolving naming conflicts

There are two areas in which name conflicts occur:

  • Variables that are defined within different scopes can have the same name. For example, a global variable can have the same name as a local or instance variable. The compiler warns you of these conflicts, but you do not have to change the names.

  • A descendant object has functions and events that are inherited from the ancestor and have the same names.

If you need to refer to a hidden variable or an ancestor's event or function, you can use dot notation qualifiers or the scope operator.

Hidden instance variables

If an instance variable has the same name as a local, shared, or global variable, qualify the instance variable with its object's name:


If a local variable and an instance variable of a window are both named birthdate, then qualify the instance variable:


If a window script defines a local variable x, the name conflicts with the X property of the window. Use a qualifier for the X property. This statement compares the two:

IF x > w_main.X THEN ...

Hidden global variables

If a global variable has the same name as a local or shared variable, you can access the global variable with the scope operator (::) as follows:


This expression compares a local variable with a global variable, both named total:

IF total < ::total THEN ...

Use prefixes to avoid naming conflicts

If your naming conventions include prefixes that identify the scope of the variable, then variables of different scopes always have different names and there are no conflicts.

For more information about the search order that determines how name conflicts are resolved, see Declarations in PowerScript Reference and Calling Functions and Events in PowerScript Reference.

Overridden functions and events

When you change the script for a function that is inherited, you override the ancestor version of the function. For events, you can choose to override or extend the ancestor event script in the painter.

You can use the scope operator to call the ancestor version of an overridden function or event. The ancestor class name, not a variable, precedes the colons:

result = w_ancestor:: FUNCTION of_func(arg1, arg2)

You can use the Super pronoun instead of naming an ancestor class. Super refers to the object's immediate ancestor:

result = Super:: EVENT ue_process()

In good object-oriented design, you would not call ancestor scripts for other objects. It is best to restrict this type of call to the current object's immediate ancestor using Super.

For how to capture the return value of an ancestor script, see Return values from ancestor scripts.

Overloaded functions

When you have several functions of the same name for the same object, the function name is considered to be overloaded. PowerBuilder determines which version of the function to call by comparing the signatures of the function definitions with the signature of the function call. The signature includes the function name, argument list, and return value.


Events and global functions cannot be overloaded.