DataWindow property expressions in PowerBuilder use dot notation to specify the controls and properties that you want to access.
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.
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 Chapter 3, “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:
For examples of DataWindow expressions, see “Using DataWindow expressions as property values”. |
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”.
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