About Me

My photo
Derek lives in Wall Street, Lee-Over-Sands, St Osyth. A mobile and event software/product designer by trade - and is keen to improve things for all the local residents - and has lived in this idyllic location since 2009.

Friday, 14 May 2010

NaN errors

So much for modern "strict data typing" programming theory. I waste so much time debugging problems with scripts that are usually related to extracting data from XML, which is a string, then trying to turn it into a number using a pre-typed variable - only to find I end up with NaN.

Rubbish. Older programming languages, such as Atari Basic in my childhood had no such issues - they would throw an occasional "type mismatch" error if it went wrong or the data was unexpectedly a string instead of a numeric value. Of course that used to be fixed by using int(variable).

This modern approach fools the app and compiler into thinking everything is fine, but simply refuses to convert the variable properly, and populates it with the useless NaN value, which of course you can't do anything with!

This means a lot of value tracing in functions needs to be done to diagnose these problems  - then finally you can spot ity, and attempt various ways of converting the original values again until you get something sensible out of Actionscript.

Screw ECMA script conventions - more trouble than its worth.

No comments:

Post a Comment