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 |
<span>dwcontrol</span>.Object.Data {.<span>buffer</span> } {.<span>datasource</span> } [<span> startrownum</span>, <br> <span>startcolnum</span>, <span>endrownum</span>, <span>endcolnum </span>] |
Parameter |
Description |
---|---|
dwcontrol |
The name of the DataWindow control or |
buffer |
The name of the buffer from which you
|
datasource |
The source of the data. Values are:
|
startrownum |
The number of the first row in the desired |
startcolnum |
The number for the first column in the |
endrownum |
The number of the last row in the range. |
endcolnum |
The number for the last column in the The row and column numbers must be enclosed in brackets and |
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 |
dw_1.Object.Data[1,1,10,4] |
1 |
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 |
integer li_fileNum |
1 |
long ll_deletedrows |
1 |
str_namelist lstr_namelist[] |
1 |
1 |
ll_deletedrows = dw_1.DeletedCount() |
1 |
lstr_namelist = & |
1 |
dw_1.Object.Data.Delete[1,1, ll_deletedrows,2] |
1 |
1 |
li_fileNum = FileOpen("C:HRDELETED.TXT", & |
1 |
LineMode!, Write!) |
1 |
FOR ll_count = 1 to UpperBound(lstr_namelist) |
1 |
FileWrite(li_fileNum, & |
1 |
String(lstr_namelist.id) + & |
1 |
" " + & |
1 |
lstr_namelist.lastname + & |
1 |
"~r~n") |
1 |
NEXT |
1 |
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 |
long ll_n |
1 |
str_namelist lstr_namelist[] |
1 |
1 |
SetNull(lstr_namelist[1].id) |
1 |
SetNull(lstr_namelist[1].lastname) |
1 |
1 |
FOR ll_n = 2 to dw_1.RowCount() |
1 |
lstr_namelist[ll_n] = lstr_namelist[1] |
1 |
NEXT |
1 |
1 |
dw_1.Object.Data[1,1, dw_1.RowCount(),2] = lstr_data |