User Seting Data Types

SO frustrating. A user of one of my data fields tells me it crashes every time he changes a User Setting.

Of course sending him a Built for Device version to generate debug line numbers won't work... because User Settings aren't supported in that type of build.

He runs an Edge 1000, which is CIQ 2.4 based. It works perfectly on my CIQ 3.0 devices, and even in the simulator as a 2.4 based 1000.

Here is my theory.... User Settings in a 2.4 device come thru as a STRING, even if they are defined as numbers. So a type mismatch crash happens.

I can easily add toNumber, toFloat, etc in the User Setting retrieval code to force it to the right type, if this is a known variance in 2.4 devices, and a known bug in the simulator.

UPDATE: adding toNumber apparently ISNT that easy. Ugh. I'm clearly doing something strange here but don't get it.

In a function - to show that toNumber() is a known symbol:
==================
var x = 5.3;
var y = x.toNumber();
System.println("X: " + x + " Y: " + y);
User[:lapFlag] = getP.getProperty("lapFlag_prop").toNumber();

Output:
==================
X: 5.300000 Y: 5
Could not find symbol 'toNumber'
Symbol Not Found Error
  • The default is something that comes in handy, as when I'm writing code, I may not have added the property yet or there's a typo on the key name. It avoids a crash, and the setting doesn't work, which is easier to debug.

    Using a wrapper will be handy when getProperty goes away in CIQ 4, and you only have to change to Application.Property. Fewer places to change the code.
  • Wait there is an FAQ! Thanks all. And now it makes sense about the boolean, but I guess I expected a type mismatch error. toNumber symbol not found seemed to suggest to me that the method wasn't found.


    The method wasn't found (the error message is accurate).

    Types have attributes (properties). Like, floats have a fractional part.

    The method is a property of the type (class).

    If you expect a method and it's missing, the type is not what you are expecting.

    Another way of look at it is monkey c doesn't really know the type until it tries to do something with it. If you code requires a particular type, your code has to get it there (because you might get another type, otherwise).