Using the DWObject variable in PowerBuilder

A PowerBuilder DWObject object is an object that exists within a DataWindow object. Each column, computed field, text control, or drawing control is a DWObject.

A DWObject reference allows you to refer directly to controls within a DataWindow.

You can use a DWObject variable to simplify DataWindow property and data expressions. A DWObject variable takes the place of several elements of the control’s dot notation.

The following syntaxes and examples show how using a DWObject variable affects property and data expressions.

Property expressions

The simple syntax for a property expression is:

dwcontrol.Object.dwcontrolname.property

You can use a DWObject variable to refer to dwcontrolname.

If the code declares a DWObject variable and assigns the control within the DataWindow to the variable, using syntax like this:

DWObject dwobjectvar

dwobjectvar = dwcontrol.Object.dwcontrolname

the syntax of the expression itself becomes:

dwobjectvar.property

For example, if the DataWindow had a column named empname, a text control named t_emplabel, and a computed field named cf_average, you could make the following assignments:

DWObject dwo_column, dwo_text, dwo_compute

dwo_column = dw_1.Object.empname

dwo_text = dw_1.Object.t_emplabel

dwo_compute = dw_1.Object.cf_average

Data expressions

You can use a DWObject variable to refer to a column in a data expression. For example, this syntax gets data for a single row and column:

dwcontrol.Object.columnname {.buffer } {.datasource } [ rownum ]

If the code declares a DWObject variable and assigns the control within the DataWindow to the variable, using syntax like this:

DWObject dwobjectvar

dwobjectvar = dwcontrol.Object.columnname

The syntax of the expression itself becomes:

dwobjectvar. {.buffer } {.datasource } [ rownum ]