From c384b23f257ccbcf42aeade15b121cd13ccaeb41 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Thu, 27 Sep 2007 13:30:20 +0000 Subject: [PATCH] 2007-09-27 15:29 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/dbinfo.ch * harbour/contrib/rdd_ads/ads1.c * harbour/source/rdd/workarea.c * harbour/source/rdd/delim1.c * harbour/source/rdd/dbf1.c * harbour/source/rdd/sdf1.c + added support for DBI_POSITIONED flag. Because some RDDs may not support phantom record then checking for EOF() does not have to be enough to detect that the cursor is positioned to phantom record. Checking for RecNo() == LastRec() + 1 does not have to work either because some RDD may use not use continuous record numbers f.e. ADT. So in code like BROWSE() if you want to be sure that current record is phantom one then (!dbInfo(DBI_POSITIONED)) should be used. --- harbour/ChangeLog | 16 ++++++++++++++++ harbour/contrib/rdd_ads/ads1.c | 4 ++++ harbour/include/dbinfo.ch | 1 + harbour/source/rdd/dbf1.c | 4 ++++ harbour/source/rdd/delim1.c | 4 ++++ harbour/source/rdd/sdf1.c | 4 ++++ harbour/source/rdd/workarea.c | 14 +++++++++++++- 7 files changed, 46 insertions(+), 1 deletion(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b30e234b5d..fe09463092 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,22 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-09-27 15:29 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/dbinfo.ch + * harbour/contrib/rdd_ads/ads1.c + * harbour/source/rdd/workarea.c + * harbour/source/rdd/delim1.c + * harbour/source/rdd/dbf1.c + * harbour/source/rdd/sdf1.c + + added support for DBI_POSITIONED flag. Because some RDDs may not + support phantom record then checking for EOF() does not have to + be enough to detect that the cursor is positioned to phantom + record. Checking for RecNo() == LastRec() + 1 does not have to + work either because some RDD may use not use continuous record + numbers f.e. ADT. So in code like BROWSE() if you want to be sure + that current record is phantom one then (!dbInfo(DBI_POSITIONED)) + should be used. + 2007-09-27 14:40 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/rdd_ads/ads1.c * harbour/source/rdd/workarea.c diff --git a/harbour/contrib/rdd_ads/ads1.c b/harbour/contrib/rdd_ads/ads1.c index e1b551e6f0..b67fbcbdec 100644 --- a/harbour/contrib/rdd_ads/ads1.c +++ b/harbour/contrib/rdd_ads/ads1.c @@ -2710,6 +2710,10 @@ static ERRCODE adsInfo( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) hb_itemPutL( pItem, pArea->fReadonly ); break; + case DBI_POSITIONED: + hb_itemPutL( pItem, pArea->fPositioned ); + break; + case DBI_LOCKCOUNT: { UNSIGNED16 u16Count; diff --git a/harbour/include/dbinfo.ch b/harbour/include/dbinfo.ch index 06fbba609c..9384def559 100644 --- a/harbour/include/dbinfo.ch +++ b/harbour/include/dbinfo.ch @@ -286,6 +286,7 @@ #define DBI_DECRYPT 141 /* Decrypt table */ #define DBI_MEMOPACK 142 /* Pack memo file */ #define DBI_DIRTYREAD 143 /* Get/Set index dirty read flag */ +#define DBI_POSITIONED 144 /* Is cursor positioned to valid record */ /* RECORD MAP (RM) support */ #define DBI_RM_SUPPORTED 150 /* has WA RDD record map support? */ diff --git a/harbour/source/rdd/dbf1.c b/harbour/source/rdd/dbf1.c index 88de93bfee..e7d45fde91 100644 --- a/harbour/source/rdd/dbf1.c +++ b/harbour/source/rdd/dbf1.c @@ -3273,6 +3273,10 @@ static ERRCODE hb_dbfInfo( DBFAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) hb_itemPutL( pItem, pArea->fValidBuffer ); break; + case DBI_POSITIONED: + hb_itemPutL( pItem, pArea->fPositioned ); + break; + case DBI_ISENCRYPTED: hb_itemPutL( pItem, pArea->fTableEncrypted ); break; diff --git a/harbour/source/rdd/delim1.c b/harbour/source/rdd/delim1.c index 8b2a9bab01..3749b60f43 100644 --- a/harbour/source/rdd/delim1.c +++ b/harbour/source/rdd/delim1.c @@ -992,6 +992,10 @@ static ERRCODE hb_delimInfo( DELIMAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) hb_itemPutL( pItem, pArea->fReadonly ); break; + case DBI_POSITIONED: + hb_itemPutL( pItem, pArea->fPositioned ); + break; + case DBI_DB_VERSION: case DBI_RDD_VERSION: { diff --git a/harbour/source/rdd/sdf1.c b/harbour/source/rdd/sdf1.c index 95e2eae6c7..0e3bcf541c 100644 --- a/harbour/source/rdd/sdf1.c +++ b/harbour/source/rdd/sdf1.c @@ -743,6 +743,10 @@ static ERRCODE hb_sdfInfo( SDFAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) hb_itemPutL( pItem, pArea->fReadonly ); break; + case DBI_POSITIONED: + hb_itemPutL( pItem, pArea->fPositioned ); + break; + case DBI_DB_VERSION: case DBI_RDD_VERSION: { diff --git a/harbour/source/rdd/workarea.c b/harbour/source/rdd/workarea.c index c4e5cb0b73..5b2fd1a54d 100644 --- a/harbour/source/rdd/workarea.c +++ b/harbour/source/rdd/workarea.c @@ -830,8 +830,20 @@ static ERRCODE hb_waInfo( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) } } hb_itemPutL( pItem, fScoped ); + break; + } + case DBI_POSITIONED: + { + ULONG ulRecCount, ulRecNo; + if( SELF_RECNO( pArea, &ulRecNo ) != SUCCESS ) + return FAILURE; + if( ulRecNo == 0 ) + hb_itemPutL( pItem, TRUE ); + else if( SELF_RECCOUNT( pArea, &ulRecCount ) != SUCCESS ) + return FAILURE; + hb_itemPutL( pItem, ulRecNo != ulRecCount + 1 ); + break; } - case DBI_RM_SUPPORTED: hb_itemPutL( pItem, FALSE ); break;