Val() returns a Quad, and no quad can represent NaN. So it is good it returns 0.
No Byte, Word, Long, Integer, Quad return value can represent NaN, because values
in the range are all valid and possible.
Changing Val() to return another type? IMHO Impossible. If you use -1 as the magic value,
Val("-1") or myVal("-1") would mean 'empty string' for you. But -1 is a valid number.
Your settings use only 0+ values, so it is OK for you to write a function that returns -1 for you.
The general function Val() can not do this, because -1 is valid signed input.
It is not a problem to use your own special function for your special requirement, is it?
Why should PB change the general function to your special requirement?
In your special case, I would change your settings reader function. If it does not find the
setting value, it returns the default. Only if it finds the settings value, it gets converted with Val().
So you simply add a check before using Val(): If the strings is empty, use default value. String not empty, use Val() value.
It would be possible with ValF() and ValD():
Code: Select all
f.f = ValF("NaN")
Debug f
d.d = ValD("NaN")
Debug d
f = ValF("") ; could return NaN, returns 0.0
Debug f
d = ValD("") ; could return NaN, returns 0.0
Debug d