From 5c55ab27cf8c3111b7dd6afc886b82d2fa1abe16 Mon Sep 17 00:00:00 2001 From: "Alexander S.Kresin" Date: Wed, 16 Aug 2000 08:34:31 +0000 Subject: [PATCH] 2000-08-16 12:35 GMT+3 Alexander Kresin --- harbour/ChangeLog | 4 ++++ harbour/contrib/rdd_ads/ads1.c | 43 ++++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 025a2933ac..534c7d66d0 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,7 @@ +2000-08-16 12:35 GMT+3 Alexander Kresin + * contrib/rdd_ads/ads1.c + * SEEK works now for numeric indexes in RDD_ADS + 2000-08-15 23:40 UTC+0800 Ron Pinkas * source/compiler/harbour.slx ! Corrected support for stringified strings to include nested string delimiters in the LITERAL. diff --git a/harbour/contrib/rdd_ads/ads1.c b/harbour/contrib/rdd_ads/ads1.c index 51b2775baa..e11655e4d0 100644 --- a/harbour/contrib/rdd_ads/ads1.c +++ b/harbour/contrib/rdd_ads/ads1.c @@ -309,19 +309,54 @@ static ERRCODE adsGoTop( ADSAREAP pArea ) static ERRCODE adsSeek( ADSAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFindLast ) { UNSIGNED16 usSeekType = ( bSoftSeek ) ? ADS_SOFTSEEK : ADS_HARDSEEK; + int uiLen = 0, uiDec = 0; + UNSIGNED8 szText[ADS_MAX_KEY_LENGTH]; + HB_TRACE(HB_TR_DEBUG, ("adsSeek(%p, %d, %p, %d)", pArea, bSoftSeek, pKey, bFindLast)); if( bFindLast ) { - AdsSeekLast( pArea->hOrdCurrent, (UNSIGNED8*) hb_itemGetCPtr( pKey ), + if( hb_itemType( pKey ) == HB_IT_STRING ) + AdsSeekLast( pArea->hOrdCurrent, (UNSIGNED8*) hb_itemGetCPtr( pKey ), (UNSIGNED16) hb_itemGetCLen( pKey ), ADS_STRINGKEY, (UNSIGNED16*) &(pArea->fFound) ); + else + { + hb_itemGetNLen( pKey, &uiLen, &uiDec ); + hb_ndtoa( hb_itemGetND( pKey ), ( char * ) szText, uiLen, uiDec ); + szText[ uiLen ] = '\0'; + AdsSeekLast( pArea->hOrdCurrent, szText, + 8, ADS_DOUBLEKEY, (UNSIGNED16*) &(pArea->fFound) ); + } } else { - AdsSeek( pArea->hOrdCurrent, (UNSIGNED8*) hb_itemGetCPtr( pKey ), - (UNSIGNED16) hb_itemGetCLen( pKey ), ADS_STRINGKEY, - usSeekType, (UNSIGNED16*) &(pArea->fFound) ); + if( hb_itemType( pKey ) == HB_IT_STRING ) + AdsSeek( pArea->hOrdCurrent, (UNSIGNED8*) hb_itemGetCPtr( pKey ), + (UNSIGNED16) hb_itemGetCLen( pKey ), ADS_STRINGKEY, usSeekType, (UNSIGNED16*) &(pArea->fFound) ); + else + { +/* + UNSIGNED8 aucKey[ADS_MAX_KEY_LENGTH]; + UNSIGNED16 usLength; + UNSIGNED16 usBufferLen; + UNSIGNED8 aucBuffer[16]; + usBufferLen = 16; + AdsGetIndexExpr( pArea->hOrdCurrent,aucBuffer, &usBufferLen ); + AdsInitRawKey( pArea->hOrdCurrent ); + AdsSetLong( pArea->hOrdCurrent, aucBuffer, hb_itemGetND( pKey ) ); + usLength = sizeof( aucKey ); + ulRetVal = AdsBuildRawKey( pArea->hOrdCurrent, aucKey, &usLength ); + printf( "\n// %d %s %s\n",ulRetVal,aucBuffer,aucKey ); + AdsSeek( pArea->hOrdCurrent, aucKey, + usLength, ADS_RAWKEY, usSeekType, (UNSIGNED16*) &(pArea->fFound) ); +*/ + hb_itemGetNLen( pKey, &uiLen, &uiDec ); + hb_ndtoa( hb_itemGetND( pKey ), ( char * ) szText, uiLen, uiDec ); + szText[ uiLen ] = '\0'; + AdsSeek( pArea->hOrdCurrent, szText, + uiLen, ADS_STRINGKEY, usSeekType, (UNSIGNED16*) &(pArea->fFound) ); + } } AdsIsFound( pArea->hTable, (UNSIGNED16 *)&(pArea->fFound) ); hb_adsCheckBofEof( pArea );