Syntax for one or all data items in a named column

Description

A DataWindow data expression can access a single item in a column or computed field when you specify the control name and a row number. It accesses all the data in the column when you omit the row number.

Syntax

dwcontrol.Object.columnname {.buffer } {.datasource } { [ rownum ] }

Parameter

Description

dwcontrol

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

columnname

The name of a column or computed field in the DataWindow object in dwcontrol. If the column or computed field does not exist at runtime, an execution error occurs.

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. For a computed field, you must specify Original because computed fields cannot be changed and do not have current values.

rownum (optional)

The row number of the desired item. The row number must be enclosed in brackets.

To access all the data in the column, omit rownum.

Return value

The expression has a datatype of Any. The expression returns a single value (for a specific row number) or an array of values (when rownum is omitted). Each value has a datatype of columnname.

Usage

Is the expression a DWObject or data? When you want to access all the data in the column, remember to specify at least one of the other optional parameters. Otherwise, the expression you specify refers to the column control, not its data. This expression refers to the DWObject empname, not the data in the column:

dw_1.Object.empname

In contrast, these expressions all refer to data in the empname column:

dw_1.Object.empname.Primary // All rows

dw_1.Object.empname[5]      // Row 5

Row numbers for computed fields When you refer to a control in a band other than the detail band (usually a computed field) you still specify a row number. For the header, footer, or summary, specify a row number of 1. For the group header or trailer, specify the group number:

dw_1.Object.avg_cf[1]

If you specify nothing after the computed field name, you refer to the computed field DWObject, not the data. For a computed field that occurs more than once, you can get all values by specifying buffer or datasource instead of rownum, just as for columns.

When the expression is an array When the expression returns an array (because there is no row number), you must assign the result to an array, even if you know there is only one row in the result.

This expression returns an array, even if there is only one row in the DataWindow control:

dw_1.Object.empname.Primary

This expression returns a single value:

dw_1.Object.empname[22]

Examples

Because the default setting is current values in the primary buffer, the following expressions are equivalent—both get the value in row 1 for the emp_name column:

dw_1.Object.emp_name[1]

dw_1.Object.emp_name.Primary.Current[1]

This statement sets the emp_name value in row 1 to Wilson:

dw_1.Object.emp_name[1] = "Wilson"

This statement gets values for all the emp_name values that have been retrieved and assigns them to an array of strings:

string ls_namearray[]

ls_namearray = dw_1.Object.emp_name.Current

This statement gets current values of emp_name from all rows in the filter buffer:

string ls_namearray[]

ls_namearray = dw_1.Object.emp_name.Filter

This statement gets original values of emp_name from all rows in the filter buffer:

string ls_namearray[]

ls_namearray = dw_1.Object.emp_name.Filter.Original

This statement gets the current value of emp_name from row 14 in the delete buffer:

string ls_name

ls_name = dw_1.Object.emp_name.Delete[14]

This statement gets the original value of emp_name from row 14 in the delete buffer:

string ls_name

ls_name = dw_1.Object.emp_name.Delete.Original[14]

This statement gets all the values of the computed field review_date:

string ld_review[]

ld_review = dw_1.Object.review_date.Original