Probably bad coding. But this has always worked (and still does) for my Edge devices (SDK 3.3). I just added a ForeRunner 955 and now it fails for that device (SDK 4.1).
I define default values for UserSettings in a global array (and overwrite that value with User-defined values if they change the value). So for example, in one source file I define: UserSettings[12,"Test",false].
In another source file, I need to define a Global Array of size X, where X is UserSettings[0]. So I do this:
Iterations = new[UserSettings[0]+1];
================
There are several issues with this. So I'll fix this sloppy code. But just for curiosity, for my EDGE devices, it runs fine. The runtime resolves the UserSettings array definition first and then can apply the "12" to the size of the Iterations array when it is defined.
But when I run it (in the simulator) for the ForeRunner, I get this. This suggests the Iteration array definition occurred before the UserSettings array was initialized. So besides poor coding (it does compile fine)... is this just an ambigious race condition - the UserSettings array may or may not be defined before Iterations uses the value?
Runtime Error on the ForeRunner device:
Error: Unhandled Exception
Exception: UnexpectedTypeException: Expected Object/Array/Dictionary/ByteArray, given null
Stack:
- <init>() at C:\Users\DaveBRILLHART\GARMIN_CIQ\ConnectIQ\MyProjects\HR_Stress_Run\source\CalcFunctions.mc:65 0x100001c0
-
Native code0xffffffff