2014-09-05 13:24 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* include/harbour.hbx
  * src/rtl/val.c
    + added new function: hb_Val( <cStr> [, <nLen> ] ) -> <nVal>
      it works like a val but set length for numeric result to passed string
      length or <nLen> parameter if is large enough.

  * src/rtl/tget.prg
    ! use hb_Val() instead of Val() for numeric GETs to replicate Clipper
      behavior for pictures longer then 10 characters.
This commit is contained in:
Przemysław Czerpak
2014-09-05 13:24:05 +02:00
parent e41b3fa69a
commit a777fd8568
4 changed files with 53 additions and 1 deletions

View File

@@ -10,6 +10,17 @@
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
*/
2014-09-05 13:24 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* include/harbour.hbx
* src/rtl/val.c
+ added new function: hb_Val( <cStr> [, <nLen> ] ) -> <nVal>
it works like a val but set length for numeric result to passed string
length or <nLen> parameter if is large enough.
* src/rtl/tget.prg
! use hb_Val() instead of Val() for numeric GETs to replicate Clipper
behavior for pictures longer then 10 characters.
2014-09-04 21:17 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* src/rtl/itemseri.c
* minor update in comments

View File

@@ -879,6 +879,7 @@ DYNAMIC hb_utf8Stuff
DYNAMIC hb_utf8SubStr
DYNAMIC hb_UTF8ToStr
DYNAMIC hb_UTF8ToStrBox
DYNAMIC hb_Val
DYNAMIC hb_ValToExp
DYNAMIC hb_ValToStr
DYNAMIC hb_Version

View File

@@ -1339,7 +1339,7 @@ METHOD unTransform() CLASS Get
ENDIF
ENDIF
xValue := Val( cBuffer )
xValue := hb_Val( cBuffer )
EXIT

View File

@@ -73,3 +73,43 @@ HB_FUNC( VAL )
else
hb_errRT_BASE_SubstR( EG_ARG, 1098, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( HB_VAL )
{
PHB_ITEM pText = hb_param( 1, HB_IT_STRING );
if( pText )
{
const char * szText = hb_itemGetCPtr( pText );
int iWidth, iDec, iLen = ( int ) hb_itemGetCLen( pText );
HB_BOOL fDbl;
HB_MAXINT lValue;
double dValue;
fDbl = hb_valStrnToNum( szText, iLen, &lValue, &dValue , &iDec, &iWidth );
if( HB_ISNUM( 2 ) )
iLen = ( int ) hb_parni( 2 );
if( fDbl && iDec > 0 )
iLen -= iDec + 1;
if( iLen > iWidth )
iWidth = iLen;
else if( iLen > 0 )
{
while( iWidth > iLen && *szText == ' ' )
{
iWidth--;
szText++;
}
}
if( ! fDbl )
hb_retnintlen( lValue, iWidth );
else
hb_retndlen( dValue, iWidth, iDec );
}
else
hb_errRT_BASE_SubstR( EG_ARG, 1098, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}