PowerBuilder syntax for DataWindow property expressions

The following sections describe syntax for property expressions:

Basic syntax for DataWindow property expressions in PowerBuilder

Description

DataWindow property expressions in PowerBuilder use dot notation to specify the controls and properties that you want to access.

Syntax

dwcontrol.Object.dwcontrolname { .property } .property { = value }

Argument

Description

dwcontrol

The name of the DataWindow control or child DataWindow in which you want to get or set properties.

Object

Object indicates that subsequent elements refer to the DataWindow object within dwcontrol.

dwcontrolname

a control within the DataWindow object. Possible values are DataWindow (for properties that apply to the whole DataWindow) or the name of a column, computed field, graph, line, oval, picture, rectangle, roundrectangle, report, TableBlob, or text control.

Nested DataWindow objects

If dwcontrolname is a column with the DropDownDataWindow style, a report, or an OLE Object control, you can specify another Object keyword and dwcontrolname to refer to properties of controls within the nested DataWindow object. You can specify Object.dwobjectname as many times as needed to refer to a deeply nested report.

For nested syntax, see Syntax for nested objects in DataWindow property expressions in PowerBuilder.

property

A property that applies to dwcontrolname. If the property requires additional qualifying properties, list the additional properties, separating them with a dot.

For lists of applicable properties, see the Property tables at the beginning of DataWindow Object Properties

value

A string whose value is to be assigned to the property.

If the property value is a number, value can either be a string whose value is a number or a numeric datatype. The value is stored as a string.

If the property value is a yes or no value, value can be either a string whose value is "yes" or "no" or a boolean value (true or false). The value is stored as "yes" or "no" strings.

If the property value can be an expression, then value can be a string that takes the form:

defaultvalue~t DataWindowexpression

where:

  • Defaultvalue is any value that is allowed for property.

  • DataWindowexpression is an expression that can include names of controls in the DataWindow and DataWindow expression functions.

  • Defaultvalue and DataWindowexpression are separated by a tab character (~t).

For examples of DataWindow expressions, see Using DataWindow expressions as property values.


Datatype

Any. The datatype of the expression is Any, but actual data is a string.

For more information about the expression's datatype, see Datatypes of DataWindow property expressions in PowerBuilder.

Examples

Example 1 Boolean property values

In this statement, the boolean value false is stored as the string "no":

dw_1.Object.DataWindow.ReadOnly = false

This statement displays the value of the ReadOnly property (either "yes" or "no") in the StaticText st_status:

st_status.Text = dw_1.Object.DataWindow.ReadOnly

When you test the value of a property in a relational expression, you must compare your test value to the stored values. For ReadOnly, stored values are yes or no, not boolean true or false:

IF dw_1.Object.DataWindow.Readonly = 'yes' THEN

This statement fails because the expression is not boolean:

IF dw_1.Object.DataWindow.Readonly THEN // Not valid

Example 2

Valid values for the Visible property are 0 and 1. You can set the property to numbers, yes and no, or true and false. Therefore, these three statements are equivalent:

dw_1.Object.street.Visible = false
dw_1.Object.street.Visible = "NO"
dw_1.Object.street.Visible = 0

Example 3

This example tests whether the X property contains a constant (which can be converted to a number) or a DataWindow expression. The code assigns a default value of 50 to the variable li_x, which remains the value if the property contains an expression the script cannot convert:

integer li_x
IF IsNumber( dw_1.Object.id.X ) THEN
      li_x = Integer( dw_1.Object.id.X )
ELSE
      li_x = 50
END IF

Example 4

This script sets the X property to a DataWindow expression. The expression causes IDs with values less than 10 to be indented:

string modstring, ls_x
ls_x = "50"
modstring = ls_x + "~t" + &
      "If(id > 10, " + ls_x + "," + &
      String(li_x + 20 ) + ")"
dw_1.Object.id.X = modstring

Example 5

This example makes three columns updatable and reports the value of the Update property in the StaticText st_status. The reported value is "yes", not true:

dw_1.Object.id.Update = true
dw_1.Object.street.Update = true
dw_1.Object.last_name.Update = true
 
st_status.Text = &
      "Updateable: id " + dw_1.Object.id.Update + &
      ", street " + dw_1.Object.street.Update + &
      ", last_name " + dw_1.Object.last_name.Update

Example 6

This example checks whether the id column is set up as a spin control. If so, it sets the spin range to 0 through 10:

IF dw_1.Object.id.EditMask.Spin = "yes" THEN
      dw_1.Object.id.EditMask.SpinRange = "0~~~~10"
END IF

Syntax for nested objects in DataWindow property expressions in PowerBuilder

Description

In PowerBuilder, DataWindow property expressions use additional Object keywords to refer to nested objects. Nested objects include composite or related nested reports and child DataWindows associated with DropDownDataWindow columns. Related nested and composite reports can include their own nested objects. You can extend the dot notation to refer to any level of nesting.

Syntax

dwcontrol.Object.nestedcontrolname { [row ] } .Object.dwcontrolname. 
   property { .property } { = value }

Argument

Description

dwcontrol

The name of the DataWindow control or child DataWindow in which you want to get or set properties.

Object

The Object keyword indicates that subsequent elements refer to the DataWindow object within dwcontrol.

nestedcontrolname

The name of a DropDownDataWindow column, nested report, or OLE Object control within the DataWindow object in dwcontrol.

About nested reports

A nested report can be one of a group of reports in the Composite presentation style or a nested report included in a base report, which is associated with a specific row.

row

When nestedcontrolname is a nested report in a base report, the number of the row the report is associated with

If the report is in a band other than the detail band, it is still associated with a row (see Usage below).

dwcontrolname

The name of a control within the nested DataWindow object. Possible values are DataWindow (for properties that apply to the whole DataWindow) or the name of a Button, Column, Computed field, Graph, GroupBox, Line, Oval, Picture, Rectangle, RoundRectangle, Report, TableBlob, or Text control.

If dwcontrolname is a column with the DropDownDataWindow style, a Report control, or an OLE Object control, you can specify an additional Object keyword and dwcontrolname to refer to properties of controls within the nested DataWindow object. You can specify Object.dwcontrolname as many times as needed to refer to a control in a deeply nested DataWindow object.

property

A property that applies to dwcontrolname. If the property requires additional qualifying properties, list the additional properties, separating them with a dot.

For lists of applicable properties, see the Property tables in DataWindow Object Properties

value

A string whose value is to be assigned to the property

For more information, see Basic syntax for DataWindow property expressions in PowerBuilder.


Datatype

Any. The datatype of the expression is Any, but the actual data is a string.

For more information about the expression's datatype, see Datatypes of DataWindow property expressions in PowerBuilder.

Usage

A nested report within a base report is usually in the detail band, and each instance of the report is associated with a row. The property expression must include a row number to identify which report to access. If the nested report is in a band other than detail, there may be only one or a few instances of the report, but it is still associated with a row. The expression must include a row number that has an instance of the report.

The following table lists the band and the row that is associated with the report:

If the report is in this band

This row is associated with the report

detail

The specified row.

header

The first row on the page. On screen, this is the first row visible in the DataWindow body.

footer

The last row on the page. On screen, this is the last row visible in the DataWindow body.

header.n (group header)

The first row of the group (where n is the group number).

trailer.n (group trailer)

The last row of the group (where n is the group number).

summary

The last row in the report.


Examples

Example 1

Suppose that a DataWindow has the Composite presentation style and includes a report called rpt_employee. The report includes a column emp_id. This expression gets the validation expression for the column:

string ls_valid
ls_valid = dw_composite.Object.rpt_employee.&
      Object.emp_id.Validation

Example 2

In a Composite DataWindow, one of the reports rpt_1 has a graph gr_1. This example turns on grid lines for the category axis of that graph. The example sets an instance variable to a default value of "not found". If the expression fails and triggers the Error event, the ExceptionSubstituteReturnValue! action causes the text "not found" to be returned so that the second assignment succeeds:

is_dwvalue = "not found"
dw_1.Object.rpt_1.Object.&
      gr_1.Category.MajorGridline = 5
st_status.Text = dw_1.Object.rpt_1.Object.&
      gr_1.Category.MajorGridline

The script for the Error event includes these lines:

action = ExceptionSubstituteReturnValue!
returnvalue = is_dwvalue

Example 3

Suppose that a DataWindow called dw_emp is a base report with employee information. The detail band includes a nested report of salary history called rpt_salary. This means there is a separate report with its own properties in each row.

The script checks whether the employee belongs to management (the value in the rank column in the base report is M). If so, the script assigns a DataWindow expression to the Color property of the salary column in the rpt_salary nested report. The expression highlights salaries that are over $60,000 in red.

Another statement sets the salary column's Mode property so the color change will be visible:

integer li_row
 
FOR li_row = 1 to RowCount( )
      IF dw_emp.Object.rank.Primary[li_row] = "M" THEN
 
       dw_emp.Object.rpt_salary[li_row].Object.&
         salary.Background.Color = &
         '255 ~t If(salary > 60000, 255, 0)'
 
       dw_emp.Object.rpt_salary[li_row].Object.&
         salary.Background.Mode = 0
 
      END IF
NEXT

Example 4

In this example there is a graph in the summary band of a base report called dw_emp. The graph is a nested report called rpt_graph_salaries. Although the graph is not related to a particular row, you still need to provide the row number associated with the summary band when you refer to its properties. This statement turns on autoscaling for the values axis:

dw_emp.Object.rpt_graph_salaries.Object.&
      gr_1.Values.AutoScale = 1

Example 5

If a column has a DropDownDataWindow edit style, there are properties that affect the column's appearance. Using nested object syntax, you can also change properties of the child DataWindow for the column. In this example, the DataWindow dw_gift allows a clerk at a nonprofit organization to record donations. The clerk can pick a standard donation amount from a drop-down DataWindow.

This example makes the drop-down DataWindow column called amount a required value and changes the display format for the dollars column in the child DataWindow:

dw_gift.Object.amount.dddw.Required = "Yes"
dw_gift.Object.amount.Object.dollars.Format = "$#,##0"