Bug in The Val() Function - Will Not Return Correct Value If Leading Zero Is Present
Darrell L.
Mississauga, ON

Nov 15, 2012
17 Posts

#### Bug in the val() function - will not return correct value if leading zero is present

I have a string that represents a number.  When I want to convert this string to a Long integer for example,
if there are leading zero(es) in the string, the returned value from the val() function is not correct.

Working correctly:
myNumberString = "1234"
myNumberValue  = val(myNumberString) <-- myNumberValue = 1234 (correct).

myNumberString = "01234"
myNumberValue  = val(myNumberString) <-- myNumberValue = 1 (incorrect).

I'm using ATEasy 8.0, 148b.

Kindly let me know if you see this as well.

Cheers,

- Darrell.

Arne V.
Almelo OV,

Nov 15, 2012
3 Posts

#### Re: Bug in the val() function - will not return correct value if leading zero is present

You have to fill the optional parameter lBase of the val procedure with 10; (=decimal)

myNumberString = "01234"
myNumberValue  = val(myNumberString,10)

See ATEasy Helpfile:
---------
If the first character is 0 and the second character is not 'x', 'X', 'b' or 'B', then the string is interpreted as an octal integer; otherwise, it is interpreted as a decimal number.

Martin S.
EVREUX,

Nov 15, 2012
6 Posts

#### Re: Bug in the val() function - will not return correct value if leading zero is present

When I run this

myNumberString = "01234"
myNumberValue  = val(myNumberString)

I get 668 which is represented 1234 in octal.
Why do you get 1 ?

So use Arne  solution to be sure

Darrell L.
Mississauga, ON

Nov 22, 2012
17 Posts

#### Re: Bug in the val() function - will not return correct value if leading zero is present

Yup, that fixed it... thanks folks.

D.