From 3e3e5efe109481736d7e1be88294e1f7ec3c8e76 Mon Sep 17 00:00:00 2001 From: Horacio Dario Roldan Kasimatis Date: Sat, 4 May 2002 20:49:12 +0000 Subject: [PATCH] 2002-05-04 17:47 UTC-0300 Horacio Roldan * include\hbrddcdx.h * source\rdd\dbfcdx\dbfcdx2.h * source\rdd\dbfcdx\dbfcdx1.c + fixed support for dbSeek(last) + added scope support: ordScope, dbOrderInfo(..scope..), ordKeyCount, ordKeyNo. ! fixed found() flag when last record in order must be filtered (eg: deleted), bug reported by Lorenzo Fiorini. + added dummy handler for DBOI_CUSTOM. --- harbour/include/hbrddcdx.h | 13 +- harbour/source/rdd/dbfcdx/dbfcdx1.c | 408 +++++++++++++++++++++------- harbour/source/rdd/dbfcdx/dbfcdx2.h | 4 + 3 files changed, 325 insertions(+), 100 deletions(-) diff --git a/harbour/include/hbrddcdx.h b/harbour/include/hbrddcdx.h index 8ac6f8310c..b7734b00b7 100644 --- a/harbour/include/hbrddcdx.h +++ b/harbour/include/hbrddcdx.h @@ -173,6 +173,10 @@ typedef struct _CDXTAG LPKEYINFO CurKeyInfo; /* current value of key expression */ LPPAGEINFO RootPage; LPKEYINFO HotKey; /* value of hot key expression */ + PHB_ITEM topScope; + LPKEYINFO topScopeKey; + PHB_ITEM bottomScope; + LPKEYINFO bottomScopeKey; } CDXTAG; typedef CDXTAG * LPCDXTAG; @@ -454,13 +458,16 @@ extern ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo extern ERRCODE hb_cdxOrderInfo( CDXAREAP pArea, USHORT uiIndex, LPDBORDERINFO pOrderInfo ); #define hb_cdxClearFilter NULL #define hb_cdxClearLocate NULL -#define hb_cdxClearScope NULL +/* #define hb_cdxClearScope NULL */ +static ERRCODE hb_cdxClearScope( CDXAREAP pArea ); #define hb_cdxCountScope NULL #define hb_cdxFilterText NULL -#define hb_cdxScopeInfo NULL +/* #define hb_cdxScopeInfo NULL */ +static ERRCODE hb_cdxScopeInfo( CDXAREAP pArea, USHORT nScope, PHB_ITEM pItem ); #define hb_cdxSetFilter NULL #define hb_cdxSetLocate NULL -#define hb_cdxSetScope NULL +/* #define hb_cdxSetScope NULL */ +static ERRCODE hb_cdxSetScope( CDXAREAP pArea, LPDBORDSCOPEINFO sInfo ); #define hb_cdxSkipScope NULL #define hb_cdxCompile NULL #define hb_cdxError NULL diff --git a/harbour/source/rdd/dbfcdx/dbfcdx1.c b/harbour/source/rdd/dbfcdx/dbfcdx1.c index c634010f47..5a39152f57 100644 --- a/harbour/source/rdd/dbfcdx/dbfcdx1.c +++ b/harbour/source/rdd/dbfcdx/dbfcdx1.c @@ -1045,6 +1045,8 @@ static void hb_cdxTagFree( LPCDXTAG pTag ) hb_itemRelease( pTag->pForItem ); } hb_cdxKeyFree( pTag->CurKeyInfo ); + hb_cdxTagClearScope( pTag, 0); + hb_cdxTagClearScope( pTag, 1); hb_xfree( pTag ); } @@ -1975,6 +1977,7 @@ static void hb_cdxTagIntNodeBuild( LPCDXTAG pTag, LPCDXDATA pData, LPPAGEINFO pP static LONG hb_cdxTagKeyFind( LPCDXTAG pTag, LPKEYINFO pKey ) { int K; + LONG ret = 0; pTag->CurKeyInfo->Tag = 0; hb_cdxTagTagOpen( pTag, 0 ); @@ -1985,27 +1988,25 @@ static LONG hb_cdxTagKeyFind( LPCDXTAG pTag, LPKEYINFO pKey ) if( K == 0 ) { hb_cdxPageRetrieveKey( pTag->RootPage, &pTag->CurKeyInfo ); - /* - if( pTag->pForItem == NULL ) - return pTag->CurKeyInfo->Tag; - else - / * TODO: test for expression * / - pTag->TagEOF = TRUE; - */ - return pTag->CurKeyInfo->Tag; + ret = pTag->CurKeyInfo->Tag; } else if( K < 0 ) { hb_cdxPageRetrieveKey( pTag->RootPage, &pTag->CurKeyInfo ); - /* - if( pTag->pForItem != NULL ) - / * TODO: test for expression * / - pTag->TagEOF = TRUE; - */ } else pTag->TagEOF = TRUE; - return 0; + + if ( pKey->Tag == CDX_MAX_REC_NUM ) { + USHORT dav; + hb_cdxPageRetrieveKey( pTag->RootPage, &pTag->CurKeyInfo ); + hb_cdxTagKeyRead( pTag, PREV_RECORD ); + if ( pTag->CurKeyInfo->Tag ) { + if ( hb_cdxKeyCompare( pKey, pTag->CurKeyInfo, &dav, FALSE ) == 0 ) + ret = pTag->CurKeyInfo->Tag; + } + } + return ret; } /* end hb_cdxTagxxx */ @@ -3556,72 +3557,98 @@ static ERRCODE hb_cdxGoEof( CDXAREAP pArea ) return retvalue; } - - -/* -static long hb_cdxDBOIKeyCount( CDXAREAP pArea ) +static BOOL hb_cdxTopScope( LPCDXTAG pTag, LPKEYINFO pKey ) { - LPKEYINFO pNewKey; - LPCDXTAG pTag; - long lKeyCount = 0; - - pTag = hb_cdxGetActiveTag( pArea->lpIndexes ); - pNewKey = hb_cdxKeyNew(); - pNewKey = hb_cdxKeyCopy( pNewKey, pTag->CurKeyInfo ); - hb_cdxTagTagOpen( pTag, 0 ); - hb_cdxTagKeyRead( pTag, TOP_RECORD ); - while( !pTag->TagEOF ) - { - lKeyCount++; - hb_cdxTagKeyRead( pTag, NEXT_RECORD ); - } - hb_cdxTagKeyFind( pTag, pNewKey ); - hb_cdxTagTagClose( pTag ); - hb_cdxKeyFree( pNewKey ); - return lKeyCount; + USHORT EndPos; + if( pTag->topScope ) + return ( hb_cdxKeyCompare( pTag->topScopeKey, pKey, &EndPos, FALSE) <= 0); + else + return TRUE; } -*/ -/* - This version of DBOIKeyCount should be fixed when scopes are implemented, the above works. - */ + +static BOOL hb_cdxBottomScope( LPCDXTAG pTag, LPKEYINFO pKey ) +{ + USHORT EndPos; + if( pTag->bottomScope ) + return ( hb_cdxKeyCompare( pTag->bottomScopeKey, pKey, &EndPos, FALSE) >= 0); + else + return TRUE; +} + +static void hb_cdxTagClearScope( LPCDXTAG pTag, USHORT nScope ) +{ + PHB_ITEM *pScope; + LPKEYINFO *pScopeKey; + + HB_TRACE(HB_TR_DEBUG, ("hb_cdxTagClearScope(%p, %hu)", pArea, nScope)); + + pScope = (nScope == 0) ? &(pTag->topScope) : &(pTag->bottomScope); + pScopeKey = (nScope == 0) ? &(pTag->topScopeKey) : &(pTag->bottomScopeKey); + if ( *pScope ) { + hb_itemRelease( *pScope ); + *pScope = NULL; + } + if ( *pScopeKey ) { + hb_cdxKeyFree( *pScopeKey ); + *pScopeKey = NULL; + } +} + + + static long hb_cdxDBOIKeyCount( CDXAREAP pArea ) { LPKEYINFO pCurKey; LPCDXTAG pTag; LPPAGEINFO pPage1, pPage2; - long lKeyCount; + long lKeyCount = 0; pTag = hb_cdxGetActiveTag( pArea ); if( pTag ) { hb_cdxIndexLockRead( pTag->pIndex, pTag ); - pCurKey = hb_cdxKeyNew(); pCurKey = hb_cdxKeyCopy( pCurKey, pTag->CurKeyInfo ); - hb_cdxTagTagOpen( pTag, 0 ); - hb_cdxTagKeyRead( pTag, TOP_RECORD ); - pPage1 = pTag->RootPage; - while ( pPage1->Child ) - pPage1 = pPage1->Child; - - lKeyCount = pPage1->uiKeys; - if ( pPage1->Right != -1 ) + if( pTag->topScope || pTag->bottomScope ) { - pPage2 = hb_cdxPageNew( pTag, 0, 0 ); - pPage2->Page = pPage1->Right; - while ( pPage2->Page != -1 ) + hb_cdxTagTagOpen( pTag, 0 ); + if( pTag->topScope ) + hb_cdxTagKeyFind( pTag, pTag->topScopeKey ); + else + hb_cdxTagKeyRead( pTag, TOP_RECORD ); + while( !pTag->TagEOF && hb_cdxBottomScope( pTag, pTag->CurKeyInfo ) ) { - hb_cdxTagPageLoad( pTag, pPage2, 1); - lKeyCount += pPage2->uiKeys; - pPage2->Page = pPage2->Right; + lKeyCount++; + hb_cdxTagKeyRead( pTag, NEXT_RECORD ); + } + } + else + { + hb_cdxTagTagOpen( pTag, 0 ); + hb_cdxTagKeyRead( pTag, TOP_RECORD ); + + pPage1 = pTag->RootPage; + while ( pPage1->Child ) + pPage1 = pPage1->Child; + + lKeyCount = pPage1->uiKeys; + if ( pPage1->Right != -1 ) + { + pPage2 = hb_cdxPageNew( pTag, 0, 0 ); + pPage2->Page = pPage1->Right; + while ( pPage2->Page != -1 ) + { + hb_cdxTagPageLoad( pTag, pPage2, 1); + lKeyCount += pPage2->uiKeys; + pPage2->Page = pPage2->Right; + } + hb_cdxPageFree( pPage2 ); } - hb_cdxPageFree( pPage2 ); } hb_cdxTagKeyFind( pTag, pCurKey ); /* hb_cdxTagTagClose( pTag ); */ hb_cdxKeyFree( pCurKey ); - hb_cdxIndexUnLockRead( pTag->pIndex, pTag ); } return lKeyCount; @@ -3655,9 +3682,6 @@ static long hb_cdxDBOIKeyNo( CDXAREAP pArea ) } */ -/* - This version of DBOIKeyNo should be fixed when scopes are implemented, the above works. - */ static long hb_cdxDBOIKeyNo( CDXAREAP pArea ) { LPKEYINFO pCurKey; @@ -3672,24 +3696,40 @@ static long hb_cdxDBOIKeyNo( CDXAREAP pArea ) hb_cdxIndexLockRead( pTag->pIndex, pTag ); pCurKey = hb_cdxKeyNew(); pCurKey = hb_cdxKeyCopy( pCurKey, pTag->CurKeyInfo ); - hb_cdxTagTagOpen( pTag, 0 ); - hb_cdxTagKeyFind( pTag, pCurKey ); - if ( !pTag->TagBOF && !pTag->TagEOF ) { - pPage1 = pTag->RootPage; - while ( pPage1->Child ) - pPage1 = pPage1->Child; - lKeyNo = pPage1->CurKey + 1; - if ( pPage1->Left != -1 ) + if( pTag->topScope || pTag->bottomScope ) + { + hb_cdxTagTagOpen( pTag, 0 ); + hb_cdxTagKeyFind( pTag, pCurKey ); + if ( hb_cdxTopScope( pTag, pTag->CurKeyInfo ) && hb_cdxBottomScope( pTag, pTag->CurKeyInfo ) ) { - pPage2 = hb_cdxPageNew( pTag, 0, 0 ); - pPage2->Page = pPage1->Left; - while ( pPage2->Page != -1 ) + while( !pTag->TagBOF && !pTag->TagEOF && hb_cdxTopScope( pTag, pTag->CurKeyInfo ) ) { - hb_cdxTagPageLoad( pTag, pPage2, 1); - lKeyNo += pPage2->uiKeys; - pPage2->Page = pPage2->Left; + lKeyNo++; + hb_cdxTagKeyRead( pTag, PREV_RECORD ); + } + } + } + else + { + hb_cdxTagTagOpen( pTag, 0 ); + hb_cdxTagKeyFind( pTag, pCurKey ); + if ( !pTag->TagBOF && !pTag->TagEOF ) { + pPage1 = pTag->RootPage; + while ( pPage1->Child ) + pPage1 = pPage1->Child; + lKeyNo = pPage1->CurKey + 1; + if ( pPage1->Left != -1 ) + { + pPage2 = hb_cdxPageNew( pTag, 0, 0 ); + pPage2->Page = pPage1->Left; + while ( pPage2->Page != -1 ) + { + hb_cdxTagPageLoad( pTag, pPage2, 1); + lKeyNo += pPage2->uiKeys; + pPage2->Page = pPage2->Left; + } + hb_cdxPageFree( pPage2 ); } - hb_cdxPageFree( pPage2 ); } } hb_cdxTagKeyFind( pTag, pCurKey ); @@ -3755,7 +3795,10 @@ ERRCODE hb_cdxGoBottom( CDXAREAP pArea ) { hb_cdxIndexLockRead( pTag->pIndex, pTag ); hb_cdxTagTagOpen( pTag, 0 ); - hb_cdxTagKeyRead( pTag, BTTM_RECORD ); + if( pTag->bottomScope ) + hb_cdxSeek( pArea, 1, pTag->bottomScope, 1 ); + else + hb_cdxTagKeyRead( pTag, BTTM_RECORD ); SELF_GOTO( ( AREAP ) pArea, pTag->CurKeyInfo->Tag ); hb_cdxIndexUnLockRead( pTag->pIndex, pTag ); } @@ -3895,7 +3938,10 @@ ERRCODE hb_cdxGoTop( CDXAREAP pArea ) { hb_cdxIndexLockRead( pTag->pIndex, pTag ); hb_cdxTagTagOpen( pTag, 0 ); - hb_cdxTagKeyRead( pTag, TOP_RECORD ); + if( pTag->topScope ) + hb_cdxSeek( pArea, 1, pTag->topScope, 0); + else + hb_cdxTagKeyRead( pTag, TOP_RECORD ); SELF_GOTO( ( AREAP ) pArea, pTag->CurKeyInfo->Tag ); hb_cdxIndexUnLockRead( pTag->pIndex, pTag ); } @@ -3947,6 +3993,17 @@ ERRCODE hb_cdxSeek( CDXAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFindLas hb_cdxIndexLockRead( pTag->pIndex, pTag ); lRecno = hb_cdxTagKeyFind( pTag, pKey2 ); + /* + if( bFindLast ) + { + USHORT dav; + hb_cdxTagKeyRead( pTag, PREV_RECORD ); + if ( pTag->CurKeyInfo->Tag ) { + if ( hb_cdxKeyCompare( pKey2, pTag->CurKeyInfo, &dav, FALSE ) == 0 ) + lRecno = pTag->CurKeyInfo->Tag; + } + } + */ pArea->fEof = pTag->TagEOF; pArea->fBof = pTag->TagBOF; /* hb_cdxKeyFree( pKey2 ); */ @@ -3984,19 +4041,25 @@ ERRCODE hb_cdxSeek( CDXAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFindLas USHORT endPos; int k; retvalue = SELF_SKIPFILTER( ( AREAP ) pArea, 1 ); - k = hb_cdxKeyCompare( pKey2, pTag->CurKeyInfo, &endPos, FALSE ); - if ( k == 0) - { - pArea->fFound = TRUE; + if ( pArea->fEof ) { + pArea->fFound = FALSE; } else { - pArea->fFound = FALSE; - if( !bSoftSeek ) + k = hb_cdxKeyCompare( pKey2, pTag->CurKeyInfo, &endPos, FALSE ); + if ( k == 0) { - //retvalue = SELF_GOTO( ( AREAP ) pArea, 0 ); - SELF_GOBOTTOM( ( AREAP ) pArea ); - retvalue = SELF_SKIP( ( AREAP ) pArea, 1 ); + pArea->fFound = TRUE; + } + else + { + pArea->fFound = FALSE; + if( !bSoftSeek ) + { + //retvalue = SELF_GOTO( ( AREAP ) pArea, 0 ); + SELF_GOBOTTOM( ( AREAP ) pArea ); + retvalue = SELF_SKIP( ( AREAP ) pArea, 1 ); + } } } } @@ -4027,6 +4090,10 @@ ERRCODE hb_cdxSeek( CDXAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFindLas /*pArea->fEof = pTag->TagEOF = TRUE; */ } } + if( !hb_cdxTopScope( pTag, pTag->CurKeyInfo ) || + !hb_cdxBottomScope( pTag, pTag->CurKeyInfo ) ) + hb_cdxGoEof( pArea ); + hb_cdxIndexUnLockRead( pTag->pIndex, pTag ); return retvalue; } @@ -4068,19 +4135,20 @@ ERRCODE hb_cdxSkipRaw( CDXAREAP pArea, LONG lToSkip ) if( !pArea->fEof ) { while( !pTag->TagEOF && lToSkip-- > 0 ) - hb_cdxTagKeyRead( pTag, NEXT_RECORD ); + { + hb_cdxTagKeyRead( pTag, NEXT_RECORD ); + if ( !pTag->TagEOF ) { + if( !hb_cdxTopScope( pTag, pTag->CurKeyInfo ) ) + hb_cdxSeek( pArea, 1, pTag->topScope, 0 ); + else if( !hb_cdxBottomScope( pTag, pTag->CurKeyInfo ) ) + pTag->TagEOF = TRUE; + } + } if( !pTag->TagEOF ) SELF_GOTO( ( AREAP ) pArea, pTag->CurKeyInfo->Tag ); else { - /*BOOL fTop; */ /* TRUE if "top" */ - /*BOOL fBottom; */ /* TRUE if "bottom" */ - /* - SUPER_GOBOTTOM( ( AREAP ) pArea ); - SUPER_SKIPRAW( ( AREAP ) pArea, 1 ); - pArea->fEof = pTag->TagEOF = TRUE; - */ hb_cdxGoEof( pArea ); } } @@ -4094,14 +4162,23 @@ ERRCODE hb_cdxSkipRaw( CDXAREAP pArea, LONG lToSkip ) } pTag->TagBOF = FALSE; while( !pTag->TagBOF && lToSkip++ < 0 ) + { hb_cdxTagKeyRead( pTag, PREV_RECORD ); + if ( !pTag->TagBOF ) { + if( !hb_cdxTopScope( pTag, pTag->CurKeyInfo ) ) + { + hb_cdxSeek( pArea, 1, pTag->topScope, 0 ); + pTag->TagBOF = TRUE; + } + else if( !hb_cdxBottomScope( pTag, pTag->CurKeyInfo ) ) + hb_cdxSeek( pArea, 1, pTag->bottomScope, 1 ); + } + } if( !pTag->TagBOF ) SELF_GOTO( ( AREAP ) pArea, pTag->CurKeyInfo->Tag ); else { - /*BOOL fTop; */ /* TRUE if "top" */ - /*BOOL fBottom; */ /* TRUE if "bottom" */ pTag->TagBOF = FALSE; SELF_GOTOP( ( AREAP ) pArea ); pArea->fBof = pTag->TagBOF = TRUE; @@ -5522,7 +5599,46 @@ ERRCODE hb_cdxOrderInfo( CDXAREAP pArea, USHORT uiIndex, LPDBORDERINFO pOrderInf hb_cdxKeyGetItem( pTag->CurKeyInfo, pOrderInfo->itmResult, uiAux ); } break; + /*------------------- */ + case DBOI_SCOPETOP : + pTag = hb_cdxGetActiveTag( pArea ); + if( pTag ) + hb_cdxScopeInfo( pArea, 0, pOrderInfo->itmResult ); + else + hb_itemClear( pOrderInfo->itmResult ); + break; + case DBOI_SCOPEBOTTOM : + pTag = hb_cdxGetActiveTag( pArea ); + if( pTag ) + hb_cdxScopeInfo( pArea, 1, pOrderInfo->itmResult ); + else + hb_itemClear( pOrderInfo->itmResult ); + break; + case DBOI_SCOPETOPCLEAR : + pTag = hb_cdxGetActiveTag( pArea ); + if( pTag ) + { + hb_cdxScopeInfo( pArea, 0, pOrderInfo->itmResult ); + hb_cdxTagClearScope( pTag, 0); + } + else + hb_itemClear( pOrderInfo->itmResult ); + break; + case DBOI_SCOPEBOTTOMCLEAR : + pTag = hb_cdxGetActiveTag( pArea ); + if( pTag ) + { + hb_cdxScopeInfo( pArea, 1, pOrderInfo->itmResult ); + hb_cdxTagClearScope( pTag, 1); + } + else + hb_itemClear( pOrderInfo->itmResult ); + break; + /*------------------- */ + case DBOI_CUSTOM : + hb_itemPutL( pOrderInfo->itmResult, 0 ); + break; case DBOI_KEYADD : hb_itemPutL( pOrderInfo->itmResult, 0 ); break; @@ -5539,13 +5655,111 @@ ERRCODE hb_cdxOrderInfo( CDXAREAP pArea, USHORT uiIndex, LPDBORDERINFO pOrderInf // ( DBENTRYP_V ) hb_cdxClearFilter : NULL // ( DBENTRYP_V ) hb_cdxClearLocate : NULL + // ( DBENTRYP_V ) hb_cdxClearScope : NULL +static ERRCODE hb_cdxClearScope( CDXAREAP pArea ) +{ + LPCDXTAG pTag; + PHB_ITEM *pScope; + + HB_TRACE(HB_TR_DEBUG, ("hb_cdxClearScope(%p)", pArea)); + + pTag = hb_cdxGetActiveTag( pArea ); + + if( pTag ) + { + hb_cdxTagClearScope( pTag, 0); + hb_cdxTagClearScope( pTag, 1); + } + return SUCCESS; +} + // ( DBENTRYP_VPLP ) hb_cdxCountScope : NULL // ( DBENTRYP_I ) hb_cdxFilterText : NULL + // ( DBENTRYP_SI ) hb_cdxScopeInfo : NULL +static ERRCODE hb_cdxScopeInfo( CDXAREAP pArea, USHORT nScope, PHB_ITEM pItem ) +{ + LPCDXTAG pTag; + PHB_ITEM *pScope; + + HB_TRACE(HB_TR_DEBUG, ("hb_cdxScopeInfo(%p, %hu, %p)", pArea, nScope, pItem)); + + pTag = hb_cdxGetActiveTag( pArea ); + + hb_itemClear( pItem ); + if( pTag ) + { + pScope = (nScope == 0) ? &(pTag->topScope) : &(pTag->bottomScope); + if ( *pScope ) { + hb_itemCopy( pItem, *pScope ); + } + } + return SUCCESS; +} + // ( DBENTRYP_VFI ) hb_cdxSetFilter : NULL // ( DBENTRYP_VLO ) hb_cdxSetLocate : NULL + // ( DBENTRYP_VOS ) hb_cdxSetScope : NULL +static ERRCODE hb_cdxSetScope( CDXAREAP pArea, LPDBORDSCOPEINFO sInfo ) +{ + LPCDXTAG pTag; + BOOL ok; + PHB_ITEM *pScope; + LPKEYINFO *pScopeKey; + + HB_TRACE(HB_TR_DEBUG, ("hb_cdxSetScope(%p, %p)", pArea, sInfo)); + + pTag = hb_cdxGetActiveTag( pArea ); + + if( pTag ) + { + pScope = (sInfo->nScope == 0) ? &(pTag->topScope) : &(pTag->bottomScope); + pScopeKey = (sInfo->nScope == 0) ? &(pTag->topScopeKey) : &(pTag->bottomScopeKey); + if( !sInfo->scopeValue ) + { + if ( *pScope ) { + hb_itemRelease( *pScope ); + *pScope = NULL; + } + if ( *pScopeKey ) { + hb_cdxKeyFree( *pScopeKey ); + *pScopeKey = NULL; + } + } + else + { + switch( pTag->uiType ) + { + case 'N' : + ok = ( sInfo->scopeValue->type & HB_IT_NUMERIC ); break; + case 'D' : + ok = ( sInfo->scopeValue->type == HB_IT_DATE ); break; + case 'L' : + ok = ( sInfo->scopeValue->type == HB_IT_LOGICAL ); break; + case 'C' : + ok = ( sInfo->scopeValue->type == HB_IT_STRING ); break; + default: + ok = FALSE; + } + if ( ok ) { + if( *pScope == NULL ) + *pScope = hb_itemNew( NULL ); + hb_itemCopy( *pScope, sInfo->scopeValue ); + *pScopeKey = hb_cdxKeyPutItem( *pScopeKey, *pScope ); + (*pScopeKey)->Tag = (sInfo->nScope == 0) ? (CDX_IGNORE_REC_NUM) : (CDX_MAX_REC_NUM); + } + else + printf("hb_cdxSetScope: scope value of wrong type"); /* DBFCDX/1051 Scope Type Mismatch */ + } + } + else + printf("hb_cdxSetScope: workarea not indexed"); + + return SUCCESS; +} + // ( DBENTRYP_VPL ) hb_cdxSkipScope : NULL // ( DBENTRYP_P ) hb_cdxCompile : NULL diff --git a/harbour/source/rdd/dbfcdx/dbfcdx2.h b/harbour/source/rdd/dbfcdx/dbfcdx2.h index 18b2ac8e41..11cc486613 100644 --- a/harbour/source/rdd/dbfcdx/dbfcdx2.h +++ b/harbour/source/rdd/dbfcdx/dbfcdx2.h @@ -141,6 +141,10 @@ static LPCDXTAG hb_cdxGetTagByNumber(CDXAREAP pArea, USHORT uiTag ); static PHB_ITEM hb_cdxKeyGetItem( LPKEYINFO pKey, PHB_ITEM pItem, USHORT uiType ); static LPCDXTAG hb_cdxReorderTagList ( LPCDXTAG TagList ); static ERRCODE hb_cdxGoEof( CDXAREAP pArea ); +static BOOL hb_cdxTopScope( LPCDXTAG pTag, LPKEYINFO pKey ); +static BOOL hb_cdxBottomScope( LPCDXTAG pTag, LPKEYINFO pKey ); +static void hb_cdxTagClearScope( LPCDXTAG pTag, USHORT nScope ); + static USHORT hb_cdxIndexCheckVersion( LPCDXINDEX pIndex ); static USHORT hb_cdxIndexUnLockRead( LPCDXINDEX pIndex, LPCDXTAG pTag );