From 8c9402290a63cf68278061d741b4d6a50bb2a188 Mon Sep 17 00:00:00 2001 From: Andi Jahja Date: Wed, 7 Jul 1999 16:20:17 +0000 Subject: [PATCH] Bruno see ChangeLog --- harbour/include/extend.h | 1 + harbour/source/rtl/arrays.c | 46 +++++++++++++++++++++++++++++++++++++ harbour/source/rtl/extend.c | 14 +++++++---- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/harbour/include/extend.h b/harbour/include/extend.h index 2c209ae4b2..aeb57af548 100644 --- a/harbour/include/extend.h +++ b/harbour/include/extend.h @@ -232,6 +232,7 @@ int hb_arrayGetType( PHB_ITEM pArray, ULONG ulIndex ); void hb_arrayDel( PHB_ITEM pArray, ULONG ulIndex ); PHB_ITEM hb_arrayClone( PHB_ITEM pArray ); void hb_arrayAdd( PHB_ITEM pArray, PHB_ITEM pItemValue ); +char * hb_arrayGetDate( PHB_ITEM pArray, ULONG ulIndex ); /* retrieves the date value contained on an array element */ int hb_itemStrCmp( PHB_ITEM pFirst, PHB_ITEM pSecond, BOOL bForceExact ); /* our string compare */ char * hb_str( PHB_ITEM pNumber, PHB_ITEM pWidth, PHB_ITEM pDec ); /* convert number to string */ diff --git a/harbour/source/rtl/arrays.c b/harbour/source/rtl/arrays.c index b6be41c943..38194fa69b 100644 --- a/harbour/source/rtl/arrays.c +++ b/harbour/source/rtl/arrays.c @@ -7,6 +7,7 @@ #include #include #include +#include HARBOUR HB_AADD(void); HARBOUR HB_ACLONE(void); @@ -50,6 +51,51 @@ static char *szArgumentError = "Argument error: incorrect type"; * Internal */ +char * hb_arrayGetDate( PHB_ITEM pArray, ULONG ulIndex ) +{ + char szDate[ 9 ]; + long lDay, lMonth, lYear; + + if( IS_ARRAY( pArray ) ) + { + if( ulIndex <= ( unsigned )hb_arrayLen( pArray ) ) + { + PHB_ITEM pItem = pArray->item.asArray.value->pItems + ulIndex - 1; + + if( IS_DATE( pItem ) && pItem->item.asDate.value > 0 ) + { + hb_dateDecode( pItem->item.asDate.value, &lDay, &lMonth, &lYear ); + + szDate[ 0 ] = ( lYear / 1000 ) + '0'; + szDate[ 1 ] = ( ( lYear % 1000 ) / 100 ) + '0'; + szDate[ 2 ] = ( ( lYear % 100 ) / 10 ) + '0'; + szDate[ 3 ] = ( lYear % 10 ) + '0'; + + szDate[ 4 ] = ( lMonth / 10 ) + '0'; + szDate[ 5 ] = ( lMonth % 10 ) + '0'; + + szDate[ 6 ] = ( lDay / 10 ) + '0'; + szDate[ 7 ] = ( lDay % 10 ) + '0'; + szDate[ 8 ] = 0; + + return szDate; + } + else + return " "; + } + else + { + hb_errorRT_BASE(EG_ARG, 1132, "Bound error", "array access"); + } + } + else + { + hb_errorRT_BASE(EG_ARG, 1068, "Argument error", "array access"); + } + return " "; +} + + BOOL hb_arrayGetBool( PHB_ITEM pArray, ULONG ulIndex ) { diff --git a/harbour/source/rtl/extend.c b/harbour/source/rtl/extend.c index d3aeacff37..7e2648d26d 100644 --- a/harbour/source/rtl/extend.c +++ b/harbour/source/rtl/extend.c @@ -118,12 +118,16 @@ char * hb_pards( WORD wParam, ... ) pItem = stack.pBase + 1 + wParam; if( pItem->type & IT_BYREF ) pItem = stack.pItems + pItem->item.asRefer.value; + + if( IS_ARRAY( pItem ) ) + { + if( wArrayIndex ) + return strcpy( stack.szDate, hb_arrayGetDate( pItem, wArrayIndex ) ); + else + return " "; + } - if( IS_ARRAY( pItem ) && wArrayIndex ) - /* TODO: implement wArrayIndex use when retrieving an array element */ - return " "; - - else if( IS_DATE( pItem ) && pItem->item.asDate.value > 0 ) + else if( IS_DATE( pItem ) && pItem->item.asDate.value > 0 ) { hb_dateDecode( pItem->item.asDate.value, &lDay, &lMonth, &lYear );