Friday, April 27, 2012

How can I get the Find() function to to search anything other than the Primary! buffer?

Create a function in your ancestor DataWindow / DataStore UserObject (pfe_dw/pfe_ds or u_dw/u_ds in PFC):

uf_Find(String as_FindExpression, Long al_StartRow, Long al_EndRow, dwBuffer ae_SearchBuffer)

Long ll_row, ll_NumRows, ll_RetValue
DataStore lds_Buffer
String ls_Filter

IF ae_SearchBuffer = Primary! THEN
// Normal search
ll_RetValue = This.Find(as_FindExpression, al_StartRow, al_EndRow)
ELSE
// Create datastore to temporarily hold the data
lds_Buffer = CREATE DataStore
lds_Buffer.DataObject = This.DataObject
IF ae_SearchBuffer = Filter! THEN
ll_NumRows = This.FilteredCount()
ELSE
ll_NumRows = This.DeletedCount()
END IF

// Copy data to temporary datastore
This.RowsCopy(1, ll_NumRows, ae_SearchBuffer, lds_Buffer, 1, Primary!)
// Search for it
ll_RetValue = lds_Buffer.Find(as_FindExpression, al_StartRow, al_EndRow)

DESTROY lds_Buffer
END IF

Return ll_RetValue

No comments:

Post a Comment