Accessing the items in a DataWindow

You can access data values in a DataWindow by using methods or DataWindow data expressions. Both methods allow you to access data in any buffer and to get original or current values.

The method you use depends on how much data you are accessing and whether you know the names of the DataWindow columns when the script is compiled.

Using methods

There are several methods for manipulating data in a DataWindow control.

GetItem methods You call GetItem methods to obtain the data that has been accepted into a specific row and column. You can also use them to check the data in a specific buffer before you update the database. You must use the method appropriate for the column’s datatype.

These methods obtain the data in a specified row and column in a specified buffer: GetItemDate, GetItemDateTime, GetItemDecimal, GetItemNumber, GetItemString, GetItemTime.

For example, the following statement assigns the value from the empname column of the first row to the variable ls_Name:

ls_Name = dw_1.GetItemString (1, "empname")

SetItem method This method sets the value of a specified row and column: SetItem.

This statement sets the value of the empname column in the first row to the string “Waters”:

dw_1.SetItem(1, "empname", "Waters")

For more information about the methods listed above, see the online Help.

Using expressions

DataWindow data expressions refer to single items, columns, blocks of data, selected data, or the whole DataWindow. You use dot notation to construct data expressions in PocketBuilder.

The Object property of the DataWindow control lets you specify expressions that refer directly to the data of the DataWindow object in the control. This direct data manipulation allows you to access small and large amounts of data in a single statement, without calling methods:

dw_1.Object.jobtitle[3] = "Programmer"

The next statement sets the value of the first column in the first row in the DataWindow to Smith:

dw_1.Object.Data[1,1] = "Smith"

For complete instructions on how to construct DataWindow data expressions, see the DataWindow Reference in the online Help.