diff --git a/harbour/ChangeLog b/harbour/ChangeLog index d002f8f30b..ce013461b6 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,10 @@ +19990831-23:10 GMT+1 Victor Szel + * source/rtl/itemapi.c + include/itemapi.h + + hb_itemSetNLen() added to set the numeric values length and number + of decimal places. This way we have a standard way to set these without + fiddling with the internals. Cool. + 19990831-22:20 GMT+1 Victor Szel * source/rtl/hvm.c ! hb_vmFunction() now resets the return value to NIL, since previously diff --git a/harbour/include/itemapi.h b/harbour/include/itemapi.h index 56a7369f5d..0610e8f429 100644 --- a/harbour/include/itemapi.h +++ b/harbour/include/itemapi.h @@ -51,6 +51,7 @@ extern char * hb_itemGetDS ( PHB_ITEM pItem, char *szDate ); extern BOOL hb_itemGetL ( PHB_ITEM pItem ); extern double hb_itemGetND ( PHB_ITEM pItem ); extern long hb_itemGetNL ( PHB_ITEM pItem ); +extern void hb_itemSetNLen ( PHB_ITEM pItem, WORD wWidth, WORD wDecimal ); extern PHB_ITEM hb_itemNew ( PHB_ITEM pNull ); extern PHB_ITEM hb_itemParam ( WORD wParam ); extern PHB_ITEM hb_itemPutC ( PHB_ITEM pItem, char *szText ); diff --git a/harbour/source/rtl/itemapi.c b/harbour/source/rtl/itemapi.c index 96ea4cf4fe..a2d8e17f54 100644 --- a/harbour/source/rtl/itemapi.c +++ b/harbour/source/rtl/itemapi.c @@ -386,6 +386,30 @@ PHB_ITEM hb_itemPutNL( PHB_ITEM pItem, long lNumber ) return pItem; } +void hb_itemSetNLen( PHB_ITEM pItem, WORD wWidth, WORD wDecimal ) +{ + if( pItem + && wWidth > 0 && wWidth <= 99 + && ( wDecimal == 0 || wDecimal < ( wWidth - 1 ) ) ) + { + switch( pItem->type ) + { + case IT_DOUBLE: + pItem->item.asDouble.length = wWidth; + pItem->item.asDouble.decimal = wDecimal; + break; + + case IT_LONG: + pItem->item.asLong.length = wWidth; + break; + + case IT_INTEGER: + pItem->item.asInteger.length = wWidth; + break; + } + } +} + ULONG hb_itemSize( PHB_ITEM pItem ) { if( pItem )