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
1 |
<span>dwcontrol</span>.<span>Object</span>.<span>dwcontrolname</span> { .<span></span><span>property</span> } .<span>property</span><span></span> { = value } |
Argument |
Description |
||
---|---|---|---|
dwcontrol |
The name of the DataWindow control or |
||
Object |
Object indicates that subsequent elements |
||
dwcontrolname |
a control within the DataWindow object. ![]() If dwcontrolname is a column with the For nested syntax, see “Syntax for nested objects |
||
property |
A property that applies to dwcontrolname. For lists of applicable properties, see the |
||
value |
A string whose value is to be assigned If the property value is a number, value can If the property value is a yes or no value, value can If the property value can be an expression, then value can
where:
For examples of DataWindow expressions, see “Using DataWindow expressions |
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”:
1 |
dw_1.Object.DataWindow.ReadOnly = false |
This statement displays the value of the ReadOnly property
(either “yes” or “no”) in the StaticText st_status:
1 |
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:
1 |
IF dw_1.Object.DataWindow.Readonly = 'yes' THEN |
This statement fails because the expression is not boolean:
1 |
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:
1 |
dw_1.Object.street.Visible = false |
1 |
dw_1.Object.street.Visible = "NO" |
1 |
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:
1 |
integer li_x |
1 |
IF IsNumber( dw_1.Object.id.X ) THEN |
1 |
li_x = Integer( dw_1.Object.id.X ) |
1 |
ELSE |
1 |
li_x = 50 |
1 |
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:
1 |
string modstring, ls_x |
1 |
ls_x = "50" |
1 |
modstring = ls_x + "~t" + & |
1 |
"If(id > 10, " + ls_x + "," + & |
1 |
String(li_x + 20 ) + ")" |
1 |
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:
1 |
dw_1.Object.id.Update = true |
1 |
dw_1.Object.street.Update = true |
1 |
dw_1.Object.last_name.Update = true |
1 |
1 |
st_status.Text = & |
1 |
"Updateable: id " + dw_1.Object.id.Update + & |
1 |
", street " + dw_1.Object.street.Update + & |
1 |
", 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:
1 |
IF dw_1.Object.id.EditMask.Spin = "yes" THEN |
1 |
dw_1.Object.id.EditMask.SpinRange = "0~~~~10" |
1 |
END IF |