Driessen,
Here is an example of creating an index using USECURRENT and progress bar:
Note - CmxKeyCount() is dbOrderInfo(DBOI_KEYCOUNTRAW, cBag, xOrder) - I used to use comix!
- Code: Select all Expand view
//Create Scope
MsgMeter( { | oMeter, oText, oDlg, lEnd | BSeekIndex( oMeter, oText, oDlg, @lEnd ) } )
STATIC FUNCTION BSeekIndex( oMeter, oText, oDlg, lEnd )
Local TmpIndx := ""
Private IndxCount := 0
oMeter:nTotal := BROKERED->(CmxKeyCount())
CursorWait()
TmpIndx := TempPath()+"BRKSEEK.CDX"
IF FILE(TmpIndx)
FERASE(TmpIndx)
ENDIF
TmpIndx := TempPath()+"BRKSEEK"
SELECT BROKERED
INDEX ON STR(SITE_ID,2,0)+ORDER_NO+STR(LINE_NO,4) TO &TmpIndx. FOR !DELETED() .AND. BrokSeekVal() USECURRENT EVAL ( IndxCount++, oMeter:Set( IndxCount ), SysRefresh(), ! lEnd )
SET INDEX TO &TmpIndx.
CursorArrow()
RETURN NIL
My function BrokSeekVal then filters the data:
- Code: Select all Expand view
FUNCTION BrokSeekVal
LOCAL RetVal := .T.
IF !Empty(mCustFrom) .OR. !Empty(mCustTo)
RetVal := LEFT(BROKERED->ACNT_NBR,LEN(ALLTRIM(mCustFrom))) >= Alltrim(mCustFrom) .AND. ;
LEFT(BROKERED->ACNT_NBR,LEN(ALLTRIM(mCustTo))) <= Alltrim(mCustTo)
ENDIF
IF RetVal .AND. ;
(!Empty(mGradeFrom) .OR. !Empty(mGradeTo))
RetVal := LEFT(BROKERED->GRADE,LEN(ALLTRIM(mGradeFrom))) >= Alltrim(mGradeFrom) .AND. ;
LEFT(BROKERED->GRADE,LEN(ALLTRIM(mGradeTo))) <= Alltrim(mGradeTo)
ENDIF
IF RetVal .AND. ;
(!Empty(mOrdFrom) .OR. !Empty(mOrdTo))
RetVal := LOWER(LEFT(BROKERED->CUST_ORDER,LEN(ALLTRIM(mOrdFrom)))) >= Lower(Alltrim(mOrdFrom)) .AND. ;
LOWER(LEFT(BROKERED->CUST_ORDER,LEN(ALLTRIM(mOrdTo)))) <= Lower(Alltrim(mOrdTo))
ENDIF
IF RetVal .AND. ;
(!Empty(mPurchFrom) .OR. !Empty(mPurchTo))
RetVal := LEFT(BROKERED->PURCH_CUST,LEN(ALLTRIM(mPurchFrom))) >= Alltrim(mPurchFrom) .AND. ;
LEFT(BROKERED->PURCH_CUST,LEN(ALLTRIM(mPurchTo))) <= Alltrim(mPurchTo)
ENDIF
IF RetVal .AND. ;
(!Empty(mTranspFrom) .OR. !Empty(mTranspTo))
RetVal := LEFT(BROKERED->HAULIER,LEN(ALLTRIM(mTranspFrom))) >= Alltrim(mTranspFrom) .AND. ;
LEFT(BROKERED->HAULIER,LEN(ALLTRIM(mTranspTo))) <= Alltrim(mTranspTo)
ENDIF
RETURN RetVal
If you needed to use another index, you will have to swap between indexes using dbsetorder - but obvioulsy the "filter" will only apply to the newly created index.