From 2807eb7bb56aa2881abc6f9073114f6b8ce6d6b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Mon, 17 Oct 2022 20:11:27 +0200 Subject: [PATCH] 2022-10-17 20:11 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * include/harbour.hbx * src/harbour.def * src/rdd/dbcmd.c + added two new functions: hb_FieldGet( | ) -> | NIL hb_FieldPut( | , ) -> | NIL They works like FieldGet() and FieldPut() but allows to use field name instead of field index. --- ChangeLog.txt | 12 +++++++++++ include/harbour.hbx | 2 ++ src/harbour.def | 2 ++ src/rdd/dbcmd.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 81c74cc536..e1f48d8a6c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -453,6 +453,18 @@ * src/rdd/workarea.c * pacified warning +2022-10-17 20:11 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * include/harbour.hbx + * src/harbour.def + * src/rdd/dbcmd.c + + added two new functions: + hb_FieldGet( | ) + -> | NIL + hb_FieldPut( | , ) + -> | NIL + They works like FieldGet() and FieldPut() but allows to use field + name instead of field index. + 2019-12-03 11:42 UTC+0100 Maurizio la Cecilia (m.lacecilia/at/gmail.com) * ChangeLog.txt * restored UTF-8 encoding after previous wrong commit (Sorry!!!) diff --git a/include/harbour.hbx b/include/harbour.hbx index ffc11a60fd..8abaada73b 100644 --- a/include/harbour.hbx +++ b/include/harbour.hbx @@ -437,7 +437,9 @@ DYNAMIC hb_FEof DYNAMIC hb_FGetAttr DYNAMIC hb_FGetDateTime DYNAMIC hb_FieldDec +DYNAMIC hb_FieldGet DYNAMIC hb_FieldLen +DYNAMIC hb_FieldPut DYNAMIC hb_FieldType DYNAMIC hb_FileDelete DYNAMIC hb_FileExists diff --git a/src/harbour.def b/src/harbour.def index 8a0d118ff2..2c5f63232a 100644 --- a/src/harbour.def +++ b/src/harbour.def @@ -524,7 +524,9 @@ HB_FUN_HB_FEOF HB_FUN_HB_FGETATTR HB_FUN_HB_FGETDATETIME HB_FUN_HB_FIELDDEC +HB_FUN_HB_FIELDGET HB_FUN_HB_FIELDLEN +HB_FUN_HB_FIELDPUT HB_FUN_HB_FIELDTYPE HB_FUN_HB_FILEDELETE HB_FUN_HB_FILEEXISTS diff --git a/src/rdd/dbcmd.c b/src/rdd/dbcmd.c index b9d6b55c5f..ae4a717673 100644 --- a/src/rdd/dbcmd.c +++ b/src/rdd/dbcmd.c @@ -2283,6 +2283,55 @@ HB_FUNC( HB_FIELDTYPE ) hb_retc_null(); } +HB_FUNC( HB_FIELDGET ) +{ + AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer(); + + if( pArea ) + { + HB_USHORT uiField; + const char * szField = hb_parc( 1 ); + + if( szField ) + uiField = hb_rddFieldIndex( pArea, szField ); + else + uiField = ( HB_FIELDNO ) hb_parni( 1 ); + + if( uiField > 0 ) + { + PHB_ITEM pItem = hb_itemNew( NULL ); + SELF_GETVALUE( pArea, uiField, pItem ); + hb_itemReturnRelease( pItem ); + } + } +} + +HB_FUNC( HB_FIELDPUT ) +{ + AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer(); + + if( pArea ) + { + HB_USHORT uiField; + const char * szField = hb_parc( 1 ); + + if( szField ) + uiField = hb_rddFieldIndex( pArea, szField ); + else + uiField = ( HB_FIELDNO ) hb_parni( 1 ); + + if( uiField > 0 ) + { + PHB_ITEM pItem = hb_param( 2, HB_IT_ANY ); + if( pItem && ! HB_IS_NIL( pItem ) ) + { + if( SELF_PUTVALUE( pArea, uiField, pItem ) == HB_SUCCESS ) + hb_itemReturn( pItem ); + } + } + } +} + HB_FUNC( HB_WAEVAL ) { PHB_ITEM pBlock = hb_param( 1, HB_IT_BLOCK );