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 |
dwcontrol.Object.dwcontrolname { .property } .property { = value } |
|
Argument |
Description |
||
|---|---|---|---|
|
dwcontrol |
The name of the DataWindow control or child |
||
|
Object |
Object indicates that subsequent elements refer |
||
|
dwcontrolname |
a control within the DataWindow object. Possible Nested If dwcontrolname is For nested syntax, see Syntax for nested |
||
|
property |
A property that applies to dwcontrolname. If the For lists of applicable properties, see the |
||
|
value |
A string whose value is to be assigned to the If the property value is a number, If the property value is a yes or no If the property value
where:
For examples of 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 2 3 |
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:
|
1 2 3 4 5 6 |
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:
|
1 2 3 4 5 6 |
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:
|
1 2 3 4 5 6 7 8 |
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:
|
1 2 3 |
IF dw_1.Object.id.EditMask.Spin = "yes" THEN dw_1.Object.id.EditMask.SpinRange = "0~~~~10" END IF |