Syntax for data in a block of rows and columns

Description

A DataWindow data expression accesses data in a range of rows and columns when you specify the starting and ending row and column numbers.

Syntax

dwcontrol.Object.Data {.buffer } {.datasource } [ startrownum, 
	startcolnum, endrownum, endcolnum ] 

Parameter

Description

dwcontrol

The name of the DataWindow control or child DataWindow in which you want to get or set data.

buffer (optional)

The name of the buffer from which you want to get or set data. Values are:

  • Primary – (Default) The data in the primary buffer (the data that has not been deleted or filtered out).

  • Delete – The data in the delete buffer (data deleted from the DataWindow control).

  • Filter – The data in the filter buffer (data that was filtered out).

datasource (optional)

The source of the data. Values are:

  • Current – (Default) The current values in the DataWindow control.

  • Original – The values that were initially retrieved from the database.

startrownum

The number of the first row in the desired range of rows.

startcolnum

The number for the first column in the range.

endrownum

The number of the last row in the range.

endcolnum

The number for the last column in the range.

The row and column numbers must be enclosed in brackets and separated by commas.

Return value

The datatype of the expression is Any. The expression returns an array of structures or user objects. There is one structure element or user object instance variable for each column in the designated range. The datatype of each element matches the datatype of the corresponding column. There is one structure or user object in the array for each row in the range of rows.

Usage

When you specify a block, the expression always returns an array and you must assign the result to an array, even if you know there is only one structure in the result.

This expression returns an array of one structure from row 22:

dw_1.Object.data[22,1,22,4]

This expression returns an array of one value from row 22, column 1:

dw_1.Object.data[22,1,22,1]

Examples

These statements both refer to data in the first ten rows and first four columns of the DataWindow object in the control dw_1. The primary buffer and current data are the default:

dw_1.Object.Data[1,1,10,4]

dw_1.Object.Data.Primary.Current[1,1,10,4]

This example gets employee IDs and last names for all the rows in the delete buffer. The IDs and names are the first two columns. It saves the information in a structure, called str_namelist, of two elements: an integer called id and a string called lastname. The structure was defined previously in the Structure painter. The list of IDs and names is then saved in the file DELETED.TXT:

integer li_fileNum

long ll_deletedrows

str_namelist lstr_namelist[]


ll_deletedrows = dw_1.DeletedCount()

lstr_namelist = &

		dw_1.Object.Data.Delete[1,1, ll_deletedrows,2]


li_fileNum = FileOpen("C:\HR\DELETED.TXT", &

		LineMode!, Write!)

FOR ll_count = 1 to UpperBound(lstr_namelist)

		FileWrite(li_fileNum, &

			String(lstr_namelist.id) + &

			" " + &

			lstr_namelist.lastname + &

			"~r~n")

NEXT

FileClose(li_fileNum)

Using the structure from the previous example that holds IDs and last names, this example sets all the IDs and last names in the DataWindow control to null:

long ll_n

str_namelist lstr_namelist[]


SetNull(lstr_namelist[1].id)

SetNull(lstr_namelist[1].lastname)


FOR ll_n = 2 to dw_1.RowCount()

		lstr_namelist[ll_n] = lstr_namelist[1]

NEXT


dw_1.Object.Data[1,1, dw_1.RowCount(),2] = lstr_data