Modifying properties at runtime

In some applications, you might want to make certain properties of controls in DataWindow objects dependent on the data, which is not known to you when you define the DataWindow object in the painter. For these situations you can define property conditional expressions, which are expressions that are evaluated at runtime.

You can use these expressions to modify the appearance and behavior of DataWindow objects conditionally and dynamically during execution. When the conditions of the expressions have been met, the results of the expressions change the values of properties of controls in the DataWindow objects.

For example, in the DataWindow object shown in Figure 23-2, the Salary Plus Benefits column has a Shadow box border highlighting each data value that is greater than $60,000.

Figure 23-2: Conditional implementation of shadow box highlighting

The sample DataWindow object shows three columns of check boxes labeled Health Ins, Life Ins, and Day Care. The fourth column, Salary Plus Benefits, has a Shadow box border around every dollar value that is greater than $60,000.

To control the display of the border, you define a conditional expression for the column’s Border property. When users run the DataWindow object, PocketBuilder changes the border of individual data values based on the condition (value greater than $60,000).

Defining an expression

Figure 23-3 shows the Salary_Plus_Benefits column selected in the Design view. To the right of the Design view, the Properties view shows properties for the column, including the Border property. Next to the Border property is a button for accessing the dialog box where you enter the expression. The button displays a red equals sign with a slash through it when no expression has been entered, and a green equals sign with no slash when it has.

You click the button to open the Border expression dialog box. A line in the figure connects the button to the dialog box. In this example, although the Border property is set to NoBorder in the Properties view, the expression defined for the property overrides the NoBorder setting at runtime.

Figure 23-3: Setting a conditional expression for the Border property

Shown at the top is a picture of the Data Window painter with a boxed area around the Border drop down list on the  General tab of the Properties view for the Salary Plus Benefits column. A line is drawn from the expression button for the Border drop down column to the expression dialog box that it opens when clicked. The expression dialog box is shown at the bottom of the picture. It has the conditional entry for drawing a shaded box border around the data for salary plus benefits that exceed sixty thousand dollars, but no border around any amount equal to or less than sixty thousand dollars.

A closer look at the expression

The expression you enter almost always begins with If. Then you specify three things: the condition, what happens if it is true, and what happens if it is false. Parentheses surround the three things and commas separate them:

If( expression, true, false )

The following expression is used in Figure 23-3. Because the expression is for the Border property, the values for true and false indicate particular borders. The value 1 means Shadow box border and the value 0 means no border:

If(salary_plus_benefits > 60000, 1, 0)

When users run the DataWindow object, PocketBuilder checks the value in the computed column called salary_plus_benefits to see if it is greater than 60,000. If it is (true), PocketBuilder displays the value with the Shadow box border. If not (false), PocketBuilder displays the value with no border.

About specifying properties

Usually you specify a number to indicate what to assign to a particular property. For example, the following list shows all of the borders you can specify and the numbers you use. If you want the border property to be Shadow box for either true or false, you specify 1 in the appropriate position in the If statement.

In the Properties view, the list of choices for setting a property includes the values that correspond to choices in parentheses. This makes it easier to define an expression for a property; you do not need to look up the values. For example, if you want to specify the 3D raised border in your expression, you use the number 6, as shown in the drop-down list.

Figure 23-4: Drop-down list for Border property values

The sample shows a drop down list of choices for setting the Border property. In parentheses, each choice shows the numeric value that corresponds to the choice.

For details on the values of properties you can set using expressions, see “Supplying property values”.

For information about properties associated with a DataWindow object, see the discussion of DataWindow object properties in the online Help.

Modifying properties programmatically

You can programmatically modify the properties of controls in a DataWindow object during execution. For more information, see the DataWindow Reference in the online Help.