The VAL function is returning zero if the string has leading white space.
Test program:
10 print val(str$(5.5))
This prints the value 0 (zero).
One possible fix that seems to work is in the function "str_to_value_keep" in file "representation.py":
defstr_to_value_keep(strval,allow_nonnum=True):ifstrval==('$',''):returnvartypes.null['%']strval=vartypes.pass_string_unpack(strval)# WJB - Remove leading (and trailing) white space from string.if(allow_nonnum):strval=strval.strip()ins=StringIO(strval)outs=StringIO()tokenise_number(ins,outs)outs.seek(0)value=util.parse_value(outs)ifnotallow_nonnum:ifutil.skip_white(ins)!='':# not everything has been parsed - errorreturnNonereturnvalue
However I don't know the parser well enough to know whether that creates any other issues.
Regards,
WJB
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the report, I've confirmed the bug in the development branch and am checking how to fix this without breaking other things.
Unfortunately representation.py is one of the oldest parts, and probably the worst part, of the code (as you will have noticed when looking for a solution). In fact I'm pretty sure this bug is a regression caused by another bug I fixed earlier and the general appallingness of that bit of the code :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The VAL function is returning zero if the string has leading white space.
Test program:
10 print val(str$(5.5))
This prints the value 0 (zero).
One possible fix that seems to work is in the function "str_to_value_keep" in file "representation.py":
However I don't know the parser well enough to know whether that creates any other issues.
Regards,
WJB
Thanks for the report, I've confirmed the bug in the development branch and am checking how to fix this without breaking other things.
Unfortunately representation.py is one of the oldest parts, and probably the worst part, of the code (as you will have noticed when looking for a solution). In fact I'm pretty sure this bug is a regression caused by another bug I fixed earlier and the general appallingness of that bit of the code :)
Fixed now in master and development branches. Thanks again for your bug report & patch.
Rob