This pronoun – PB Docs 2017

This pronoun

Description

The pronoun This in a PowerBuilder script refers to the window,
user object, menu, application object, or control that owns the current
script.

Usage

Why include This

Using This allows you to make ownership explicit. The following
statement refers to the current object’s X property:

When optional but helpful

In the script for an object or control, you can refer to the
properties of the object or control without qualification, but it is
good programming practice to include This to make the script clear and
easy to read.

When required

There are some circumstances when you must use This. When a global
or local variable has the same name as an instance variable,
PowerBuilder finds the global or local variable first. Qualifying the
variable with This allows you to refer to the instance variable instead
of the global variable.

Examples

Example 1

This statement in a script for a menu places a check mark next to
the menu selection:

Example 2

In this function call, This passes a reference to the object
containing the script:

Example 3

If you omit This, “x” in the following statement refers to a local
variable x if there is one defined (the script adds 50 to the variable
x, not to the X property of the control). It refers to the object’s X
property if there is no local variable:

Example 4

Use This to ensure that you refer to the property. For example, in
the following statement in the script for the Clicked event for a
CommandButton, clicking the button changes the horizontal position of
the button (changes the button’s X property):


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