Schultz’s PowerBuilder Notes

System Functions

Evaluate( )

The evaluate( ) function is available for use with Describe( ). Evaluate( ) lets you evaluate DataWindow expressions within a script using data in the DataWindow. It has the following syntax:

Evaluate(‘Expression’, Rownumber)

The expression usually includes DataWindow painter functions that cannot be called in a script. The following example returns the display value for the dept_id column for the current row:

String ls_rownum., ls_return

Ls_rownum =  String(dw_1.GetRow( ))
Ls_return = dw_1.Describe(“Evaluate(‘LookUpDisplay(dept_id)’,” + ls_rownum + “)”)

LookupDisplay() is a common use of Evaluate()

Ls_worker_nm = dw_1.Describe(“Evaluate(‘LookupDisplay(location)”, 1)”)

Find( )

The following snippet does a case insensitive Find( )

ll_row_cnt = ids_win_dw.rowcount( )
as_window_name = Lower(as_window_name)
as_dw_name = Lower(as_dw_name)
ls_findexp = "Lower(window_name) = '" + as_window_name + "' and Lower(datawindow_name) = '" + as_dw_name + "'"

ll_row = ids_win_dw.Find(ls_findexp, 1, ll_row_Cnt)


dwcontrol RowsDiscard (startrow, endrow, buffer )


Dw_1.SetSort(“status A, salary D”)

Dw_1.Sort( )

You can also sort by column number instead of column name.

Dw_1.SetSort(‘#1 A, #4 D”)

To sort a DataWindow object with groups, call GroupCalc( ) after you call Sort( ). GroupCalc forces the DataWindow engine to recalculate the breaks in the grouping levels after you have added or modified rows in a DataWindow.

To have a “Specify Sort Columns” dialog box appear, set a string variable to NULL, and pass it as the argument to SetSort( ). A subsequent Sort( ) will open the dialog box.

How do I change a column’s tab order is script?

Dw_1.SetTabOrder(column, tabnumber)

What if AcceptText() causes a validation error?

It will return a -1


May 26, 2008 - Posted by | Powerscript | , , , , , , , , , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: