diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 351496afb9..39e5c69e41 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,9 @@ +20000220-23:05 GMT+3 Alexander Kresin + * contrib/rdd_ads/ads1.c + * memo handling changed - proposal of Brian Hays + * contrib/rdd_ads/ads1.c + * improvement of AdsKeyNo() and AdsKeyCount() + 20000220-19:55 GMT+3 Alexander Kresin * source/pp/stdalone/hbpp.c * source/pp/hbppint.c diff --git a/harbour/contrib/rdd_ads/ads1.c b/harbour/contrib/rdd_ads/ads1.c index cba1b6ff0d..4ceb216686 100644 --- a/harbour/contrib/rdd_ads/ads1.c +++ b/harbour/contrib/rdd_ads/ads1.c @@ -434,16 +434,22 @@ static ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) UNSIGNED32 pulLen; AdsGetFieldName( pArea->hTable, uiIndex, szName, &pusBufLen ); - AdsGetMemoLength( pArea->hTable, szName, &pulLen ); - if( pulLen > 0 ) - { - pucBuf = (UNSIGNED8*) hb_xgrab( pulLen ); - AdsGetString( pArea->hTable, szName, pucBuf, &pulLen, ADS_NONE ); - hb_itemPutCL( pItem, ( char * ) pucBuf, pulLen ); - hb_xfree( pucBuf ); - } + if ( AdsGetMemoLength( pArea->hTable, szName, &pulLen ) == + AE_NO_CURRENT_RECORD ) + hb_itemPutC( pItem, "" ); else - hb_itemPutC( pItem, "" ); + { + if( pulLen > 0 ) + { + pulLen++; // make room for NULL + pucBuf = (UNSIGNED8*) hb_xgrab( pulLen ); + AdsGetString( pArea->hTable, szName, pucBuf, &pulLen, ADS_NONE ); + hb_itemPutCL( pItem, ( char * ) pucBuf, pulLen ); + hb_xfree( pucBuf ); + } + else + hb_itemPutC( pItem, "" ); + } break; } diff --git a/harbour/contrib/rdd_ads/adsfunc.c b/harbour/contrib/rdd_ads/adsfunc.c index 0d3feeb538..37352572ba 100644 --- a/harbour/contrib/rdd_ads/adsfunc.c +++ b/harbour/contrib/rdd_ads/adsfunc.c @@ -117,7 +117,7 @@ HARBOUR HB_ADSSETDEFAULT( void ) HARBOUR HB_ADSSETDELETED( void ) { UNSIGNED16 usShowDeleted = hb_parl( 1 ); - AdsShowDeleted( usShowDeleted ? 0 : 1 ); + AdsShowDeleted( usShowDeleted ); } HARBOUR HB_ADSBLOB2FILE( void ) @@ -181,18 +181,31 @@ HARBOUR HB_ADSKEYNO( void ) pArea = (ADSAREAP) hb_rddGetCurrentWorkAreaPointer(); if( pArea ) { - if( ISNUM( 1 ) ) - { - ordNum = hb_parni( 1 ); - AdsGetIndexHandleByOrder( pArea->hTable, ordNum, &hIndex ); + if( hb_pcount() > 0 ) + { + if( ISNUM( 1 ) ) + { + ordNum = hb_parni( 1 ); + AdsGetIndexHandleByOrder( pArea->hTable, ordNum, &hIndex ); + } + else + { + ordName = hb_parc( 1 ); + AdsGetIndexHandle( pArea->hTable, ordName, &hIndex ); + } + AdsGetKeyNum ( hIndex, ADS_IGNOREFILTERS, &pulKey); } else { - ordName = hb_parc( 1 ); - AdsGetIndexHandle( pArea->hTable, ordName, &hIndex ); + if( pArea->hOrdCurrent != 0) + { + hIndex = pArea->hOrdCurrent; + AdsGetKeyNum ( hIndex, ADS_IGNOREFILTERS, &pulKey); + } + else + AdsGetRecordNum ( pArea->hTable, ADS_IGNOREFILTERS, &pulKey); } - AdsGetKeyNum ( hIndex, ADS_IGNOREFILTERS, &pulKey); hb_retnl( pulKey ); } else @@ -210,20 +223,25 @@ HARBOUR HB_ADSKEYCOUNT( void ) pArea = (ADSAREAP) hb_rddGetCurrentWorkAreaPointer(); if( pArea ) { - if( ISNUM( 1 ) ) + if( hb_pcount() > 0 ) { - ordNum = hb_parni( 1 ); - AdsGetIndexHandleByOrder( pArea->hTable, ordNum, &hIndex ); + if( ISNUM( 1 ) ) + { + ordNum = hb_parni( 1 ); + AdsGetIndexHandleByOrder( pArea->hTable, ordNum, &hIndex ); + } + else + { + ordName = hb_parc( 1 ); + AdsGetIndexHandle( pArea->hTable, ordName, &hIndex ); + } } else - { - ordName = hb_parc( 1 ); - AdsGetIndexHandle( pArea->hTable, ordName, &hIndex ); - } + hIndex = (pArea->hOrdCurrent == 0)? pArea->hTable:pArea->hOrdCurrent; - AdsGetKeyCount ( hIndex, ADS_IGNOREFILTERS, &pulKey); + AdsGetRecordCount ( hIndex, ADS_IGNOREFILTERS, &pulKey); hb_retnl( pulKey ); } else hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSKEYCOUNT" ); -} +} \ No newline at end of file