I know that the documentation says this will happen, but the behaviour is still inconsistent. I get that the CIQ1 behaviour may never change due to limited VM space, but it would be nice if:
- The simulator had the same behaviour
- The behaviour for CIQ2 devices (return null) was documented
I previously checked whether the first char was a number or not, but I wanted to save code space. Clearly that was a mistake.
Environment
CIQ SDK 2.3.2
FR935 FW 5.10 (null)
FR920XT FW9.30 (invalid value)
(I have reason to believe this also happens on Fenix 3 HR)
Reproduction procedure
Create a simple data field with the attached code.
Run it on CIQ2 device or simulator (any device).
Output looks like:
x = hello world
x.toNumber() = null
x.toFloat() = null
Run it on CIQ1 device and it crashes with an Invalid Value error (just like the doc says).
// Set the label of the data field here.
function initialize<[]> {
SimpleDataField.initialize<[]>;
label = "My Label";
var x = "hello world";
var y = x.toNumber<[]>;
System.println<["x = " + x]>;
System.println<["x.toNumber<[]> = " + y]>;
var z = x.toNumber<[]>;
System.println<["x.toFloat<[]> = " + z]>;
}