Evaluating DataWindow expressions in the Describe function

The Describe function provides a way to evaluate DataWindow expressions outside their usual context. The Evaluate function, which is used only within Describe, allows you to evaluate DataWindow expressions within a script using data in the DataWindow.

Evaluate has the following syntax:

dwcontrol.Describe ("Evaluate ( 'expression' , rownumber ) " )

Expression is the expression you want to evaluate and rownumber is the number of the row for which you want to evaluate the expression. The expression can include DataWindow expression functions that cannot be called in a script.

This example displays in the title of the DataWindow control the current page for the current row in the DataWindow:

string ls_modstring, ls_rownum
ls_rownum = String(dw1.GetRow())

ls_modstring = "Evaluate('Page()'," + ls_rownum +")"
// The resulting string, for row 99, would be:
// Evaluate('Page()', 99)

Parent.Title = &
"Current page: "+ dw1.Describe(ls_modstring)

This example returns the display value for the dept_id column for row 5:

dw1.Describe("Evaluate('LookUpDisplay(dept_id)', 5)")

Expressions that apply to all rows

To evaluate an expression that applies to all rows, specify 0 for the  rownumber argument. This example calculates the sum of the salary column in the current DataWindow. It will return the expression's result or "!" if the expression is not valid:

dw1.Describe("Evaluate('Sum(Salary)', 0)")

Evaluating user-specified expressions

In some types of applications, you might use Evaluate to get the result of an expression the user specifies. For example, users might specify the type of aggregation they want to see. This example evaluates an expression specified in a SingleLineEdit. It applies to all rows:

dw1.Describe("Evaluate('" + sle_expr.Text + "', 0)")