diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9f8edc9385..0cc5598df7 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,10 @@ +19991121-17:50 GMT+1 Bruno Cantero + * include/rddapi.h + source/rdd/dbcmd.c + source/rdd/dbf1.c + + Additional feature: __dbPack( [], [] ) + executes every records. + 19991121-17:33 GMT+1 Victor Szel * source/compiler/expropt.c ! $ optimization fixed for strings containing Chr(0), now 4 more RTL_TESTs diff --git a/harbour/include/rddapi.h b/harbour/include/rddapi.h index dc01328de1..c27b56a0b5 100644 --- a/harbour/include/rddapi.h +++ b/harbour/include/rddapi.h @@ -232,6 +232,8 @@ typedef struct BYTE bDay; BOOL fRecordChanged; /* Record changed */ ULONG ulRecCount; /* Total records */ + PHB_ITEM itmEval; /* EVAL expression for __dbPack() */ + ULONG ulEvery; /* Every records for eval itmEval */ } DBEXTENDINFO; typedef DBEXTENDINFO * LPDBEXTENDINFO; diff --git a/harbour/source/rdd/dbcmd.c b/harbour/source/rdd/dbcmd.c index ee6aa1cd41..b82194ae24 100644 --- a/harbour/source/rdd/dbcmd.c +++ b/harbour/source/rdd/dbcmd.c @@ -1996,7 +1996,16 @@ HARBOUR HB___DBSETLOCATE( void ) HARBOUR HB___DBPACK( void ) { if( pCurrArea ) + { + /* Additional feature: __dbPack( [, [] ) + Code Block to execute for every record. */ + ( ( AREAP ) pCurrArea->pArea )->lpExtendInfo->itmEval = hb_param( 1, IT_BLOCK ); + ( ( AREAP ) pCurrArea->pArea )->lpExtendInfo->ulEvery = hb_parnl( 2 ); + if( !( ( AREAP ) pCurrArea->pArea )->lpExtendInfo->ulEvery ) + ( ( AREAP ) pCurrArea->pArea )->lpExtendInfo->ulEvery = 1; SELF_PACK( ( AREAP ) pCurrArea->pArea ); + ( ( AREAP ) pCurrArea->pArea )->lpExtendInfo->itmEval = NULL; + } else hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "__DBPACK" ); } diff --git a/harbour/source/rdd/dbf1.c b/harbour/source/rdd/dbf1.c index bf43257628..d5577914c4 100644 --- a/harbour/source/rdd/dbf1.c +++ b/harbour/source/rdd/dbf1.c @@ -45,6 +45,7 @@ #include "errorapi.h" #include "dates.h" #include "langapi.h" +#include "ctoharb.h" typedef struct _DBFHEADER { @@ -996,6 +997,7 @@ static ERRCODE dbfGetValueFile( AREAP pArea, USHORT uiIndex, void * pFile ) LPFIELD pField; HB_TRACE(HB_TR_DEBUG, ("dbfGetValueFile(%p, %hu, %p)", pArea, uiIndex, pFile)); + HB_SYMBOL_UNUSED( pFile ); if( uiIndex > pArea->uiFieldCount ) return FAILURE; @@ -1018,6 +1020,7 @@ static ERRCODE dbfGetValueFile( AREAP pArea, USHORT uiIndex, void * pFile ) * ( szText + pField->uiLen ) = szEndChar; } ( ( LPDBFMEMO ) pField->memo )->fChanged = FALSE; + return SUCCESS; } @@ -1375,7 +1378,7 @@ static ERRCODE dbfOpenMemFile( AREAP pArea, LPDBOPENINFO pOpenInfo ) static ERRCODE dbfPack( AREAP pArea ) { - ULONG ulRecCount, ulRecIn, ulRecOut; + ULONG ulRecCount, ulRecIn, ulRecOut, ulEvery; BOOL bDeleted; PHB_ITEM pError; BYTE * pBuffer, pEOF[ 1 ]; @@ -1400,11 +1403,25 @@ static ERRCODE dbfPack( AREAP pArea ) ulRecOut = 0; ulRecIn = 1; + ulEvery = 0; while ( ulRecIn <= ulRecCount ) { SELF_GOTO( pArea, ulRecIn ); SELF_DELETED( pArea, &bDeleted ); + /* Execute the Code Block */ + if( pArea->lpExtendInfo->itmEval ) + { + ulEvery++; + if( ulEvery >= pArea->lpExtendInfo->ulEvery ) + { + ulEvery = 0; + hb_vmPushSymbol( &hb_symEval ); + hb_vmPush( pArea->lpExtendInfo->itmEval ); + hb_vmDo( 0 ); + } + } + if( !bDeleted ) { ulRecOut++; @@ -1418,6 +1435,15 @@ static ERRCODE dbfPack( AREAP pArea ) } ulRecIn++; } + + /* Execute the Code Block for pending record */ + if( pArea->lpExtendInfo->itmEval && ulEvery > 0 ) + { + hb_vmPushSymbol( &hb_symEval ); + hb_vmPush( pArea->lpExtendInfo->itmEval ); + hb_vmDo( 0 ); + } + hb_dbfUpdateHeader( pArea, ulRecOut ); /* Write EOF */