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
|
1 |
dwcontrol.Object.Data {.buffer } {.datasource } [ startrownum, startcolnum, endrownum, endcolnum ] |
|
Parameter |
Description |
|---|---|
|
dwcontrol |
The name of the DataWindow control or child |
|
buffer (optional) |
The name of the buffer from which you want to get
|
|
datasource (optional) |
The source of the data. Values
|
|
startrownum |
The number of the first row in the desired range of |
|
startcolnum |
The number for the first column in the |
|
endrownum |
The number of the last row in the |
|
endcolnum |
The number for the last column in the The row and column numbers must be enclosed |
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:
|
1 |
dw_1.Object.data[22,1,22,4] |
This expression returns an array of one value from row 22, column
1:
|
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:
|
1 2 |
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:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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:HRDELETED.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:
|
1 2 3 4 5 6 7 8 9 10 11 |
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 |