Faster Code For Each Row DataWindow In PowerBuilder
Bad Code
1 2 3 4 5 6 7 8 9 10 |
Long ll_row_count, ll_curr_dept_id, ll_dept_id ll_dept_id = 1 ll_row_count = dw_1.RowCount() For ll_row = 1 To ll_row_count ll_curr_dept_id = dw_1.Object.dept_id[ll_row] If ll_curr_dept_id <> ll_dept_id Then Continue // process the found row Next |
Good Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
Long ll_row_count, ll_row, ll_curr_dept_id, ll_dept_id String ls_search_expr ll_dept_id = 1 ll_row = 0 ll_row_count = dw_1.RowCount() ls_search_expr = "dept_id=" + String(ll_dept_id) Do While True ll_row = dw_1.Find(ls_search_expr, ll_row + 1, ll_row_count) If ll_row = 0 Then Exit // process the found row If ll_row = ll_row_count Then Exit // prevent eternal loop when the last row satisfies the search condition Loop |
Good Luck!
Subscribe
Login
0 Comments
Oldest