Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #11455 > unrolled thread

Bug in Val()

Started byMartin <Martin@spam.spam>
First post2018-03-06 13:28 +0000
Last post2018-03-06 23:56 -0800
Articles 6 — 4 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  Bug in Val() Martin <Martin@spam.spam> - 2018-03-06 13:28 +0000
    Re: Bug in Val() dlzc <dlzc1@cox.net> - 2018-03-06 06:05 -0800
      Re: Bug in Val() Martin <Martin@spam.spam> - 2018-03-06 15:17 +0000
    Re: Bug in Val() Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> - 2018-03-06 15:15 +0100
      Re: Bug in Val() Martin <Martin@spam.spam> - 2018-03-06 15:18 +0000
    Re: Bug in Val() Mathias <mathias.hakansson@consultec.se> - 2018-03-06 23:56 -0800

#11455 — Bug in Val()

FromMartin <Martin@spam.spam>
Date2018-03-06 13:28 +0000
SubjectBug in Val()
Message-ID<p7m519$u20$1@dont-email.me>
Working with a CSV and getting the data into our software

"500,000.00"

Val() returns 500 NOT 500000

Taken me ages, checking our CSV importer (as the VO one does the same 
truncation into a numeric field).

So used my own into an array and parsing that.

Just to find that Val() is broken

Off to write my own now!


aghhhhhhhh!!!!!!!!!!!!!!!!

[toc] | [next] | [standalone]


#11456

Fromdlzc <dlzc1@cox.net>
Date2018-03-06 06:05 -0800
Message-ID<2b3d825c-3127-4ca8-ad1b-383feb2a75c3@googlegroups.com>
In reply to#11455
Dear Martin:

On Tuesday, March 6, 2018 at 6:28:11 AM UTC-7, Martin wrote:
> Working with a CSV and getting the data into our software
> 
> "500,000.00"
> 
> Val() returns 500 NOT 500000

What is set as your decimal separator, and thousands separator, when you do the conversion?

cConvertNow := strtran( cStringWithCommas, "," )

David A. Smith

[toc] | [prev] | [next] | [standalone]


#11458

FromMartin <Martin@spam.spam>
Date2018-03-06 15:17 +0000
Message-ID<p7mbec$gdj$1@dont-email.me>
In reply to#11456
Just use usual UK , for thousands and a decimal point

On 06/03/2018 14:05, dlzc wrote:
> Dear Martin:
> 
> On Tuesday, March 6, 2018 at 6:28:11 AM UTC-7, Martin wrote:
>> Working with a CSV and getting the data into our software
>>
>> "500,000.00"
>>
>> Val() returns 500 NOT 500000
> 
> What is set as your decimal separator, and thousands separator, when you do the conversion?
> 
> cConvertNow := strtran( cStringWithCommas, "," )
> 
> David A. Smith
> 

[toc] | [prev] | [next] | [standalone]


#11457

FromKarl Faller <mail_withoutthat_@_drei-f_andthat_.de>
Date2018-03-06 15:15 +0100
Message-ID<i78t9d104nj1rh0mav57jupe9uovl42895@4ax.com>
In reply to#11455
Martin,
Help says: ...However, if <cNumber>  is not entirely a valid numeric
expression but does contain decimal numerics, Val() evaluates it until
it reaches a second decimal point, the first non-numeric character, or
the end of the expression...

So, what do you expect? 
Garbage in, garbage out ;-)

Karl

>Working with a CSV and getting the data into our software
>
>"500,000.00"
>
>Val() returns 500 NOT 500000
>
>Taken me ages, checking our CSV importer (as the VO one does the same 
>truncation into a numeric field).
>
>So used my own into an array and parsing that.
>
>Just to find that Val() is broken
>
>Off to write my own now!
>
>
>aghhhhhhhh!!!!!!!!!!!!!!!!
Regards

Karl

[toc] | [prev] | [next] | [standalone]


#11459

FromMartin <Martin@spam.spam>
Date2018-03-06 15:18 +0000
Message-ID<p7mbgb$gdj$2@dont-email.me>
In reply to#11457
But you still would expect it to handle a thosand separator

Oh well lesson learnt after over 30 years of XBase


On 06/03/2018 14:15, Karl Faller wrote:
> Martin,
> Help says: ...However, if <cNumber>  is not entirely a valid numeric
> expression but does contain decimal numerics, Val() evaluates it until
> it reaches a second decimal point, the first non-numeric character, or
> the end of the expression...
> 
> So, what do you expect?
> Garbage in, garbage out ;-)
> 
> Karl
> 
>> Working with a CSV and getting the data into our software
>>
>> "500,000.00"
>>
>> Val() returns 500 NOT 500000
>>
>> Taken me ages, checking our CSV importer (as the VO one does the same
>> truncation into a numeric field).
>>
>> So used my own into an array and parsing that.
>>
>> Just to find that Val() is broken
>>
>> Off to write my own now!
>>
>>
>> aghhhhhhhh!!!!!!!!!!!!!!!!
> Regards
> 
> Karl
> 

[toc] | [prev] | [next] | [standalone]


#11462

FromMathias <mathias.hakansson@consultec.se>
Date2018-03-06 23:56 -0800
Message-ID<ade42794-48de-4c69-ac0e-be1470d44f10@googlegroups.com>
In reply to#11455
Den tisdag 6 mars 2018 kl. 14:28:11 UTC+1 skrev Martin:
> Working with a CSV and getting the data into our software
> 
> "500,000.00"
> 
> Val() returns 500 NOT 500000
> 
> Taken me ages, checking our CSV importer (as the VO one does the same 
> truncation into a numeric field).
> 
> So used my own into an array and parsing that.
> 
> Just to find that Val() is broken
> 
> Off to write my own now!
> 
> 
> aghhhhhhhh!!!!!!!!!!!!!!!!

It's the same in sweden. Thousand separator is " " (space), but Val("500 000,00" is 500. You will need to trim the thousand separator first. I often read texfiles where the numbers don't have decimal separators at all, but when reading prices the two last characters are decimals. In that case I divide by Pow(10, noOfDecimals).

/Mathias

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web