diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e188066a7f..6ab2f525ab 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,8 @@ +19990520-20:07 EST David G. Holm + Thanks go to "Victor Szel" again! + * source/rtl/strings.c + - VAL sets the number of integer digits and decimal places for the result + 19990520-19:35 EST David G. Holm Thanks go to "Victor Szel" * source/compiler/harbour.l diff --git a/harbour/source/rtl/strings.c b/harbour/source/rtl/strings.c index da28bc6f91..88f52aa3ef 100644 --- a/harbour/source/rtl/strings.c +++ b/harbour/source/rtl/strings.c @@ -6,7 +6,7 @@ #include #include -/* TODO: search this file for TODO and find 'em! */ +extern STACK stack; #define HB_ISSPACE(c) ((c) == 9 || (c) == 10 || (c) == 13 || (c) == 32) @@ -955,13 +955,13 @@ HARBOUR STRTRAN( void ) _retc(""); } -/* returns an integer value of "numerical string" */ +/* returns the numeric value of a character string representation of a number */ double hb_strVal( char *szText ) { return atof(szText); } -/* returns an integer value of "numerical string" */ +/* returns the numeric value of a character string representation of a number */ HARBOUR VAL( void ) { if( _pcount() == 1 ) @@ -969,7 +969,19 @@ HARBOUR VAL( void ) PITEM pText = _param(1, IT_STRING); if( pText ) + { + int nWidth, nDec = 0; + char * ptr = strchr( pText->value.szText, '.' ); + if( ptr ) + { + nWidth = ptr - pText->value.szText; + nDec = strlen( ptr + 1 ); + } + else nWidth = strlen( pText->value.szText ); _retnd(hb_strVal(pText->value.szText)); + stack.Return.wLength = nWidth; + stack.Return.wDec = nDec; + } else { PITEM pError = _errNew();