(FMX) undeclared variables error

Is it possible to somehow make MX give errors (or at least warnings) when you use undeclared variables or properties, or at least methods!!!

The amount of time I lose (and hair I pull out!) trying to debug something not working and find out whats wrong, only to realize hours later that there isnt anything wrong with the logic or algorithms etc. but it turns out its just a little typo error in the name of a variable or method etc… e.g. MovieClip.Coutner instead of MovieClip.Counter…

I want it to say immediately (as soon as I press ctrl+enter or debug etc.) that there is no such property instead of immediately creating one and initing it to zero!!
the "option explicit " statement in VB was perfect…I wanna have to explicitly declare all my variables and properties and methods.
thx

there was something with “strict”, haven’t looked into that much…try a google search…

just checked, as everything, it’s in Moocks bible, so you can read this:
http://moock.org/asdg/technotes/strict/
…not exactly what you need…


Object.prototype.__resolve = function(request){
	if (_global[request] != undefined) return _global[request];
	trace("Warning: Attempt was made to access a non-existing "+request+" in "+this);
	return undefined;
};


a = 1;
b = "2";
c = function(){};
d = null;

trace(a);
trace(b);
trace(c);
trace(d);

trace(e);
e();
if (e*10 == 0){
	trace(e);
}

/*output:
1
2
[type Function]
null
Warning: Attempt was made to access a non-existing e in _level0
undefined
Warning: Attempt was made to access a non-existing e in _level0
Warning: Attempt was made to access a non-existing e in _level0
Warning: Attempt was made to access a non-existing e in _level0
undefined
*/

what exactly calls the __resolve function? :slight_smile:

The Flash player - when a variable is not defined and its asked to get it - baically exactly what high1memo described

That looks like an interesting peice of code! and I definetly will be looking into it. But am I mistaken in thinking that it only checks global variables? i.e. it wont work on properties of objects? (e.g. Movie1.a, Movie1.b etc.?

If what I juz said above isnt true (ie. it WILL work with all variables, (local, global etc.) then thats great!! but it still only solves half the problem:

i.e. if I say "Movie1.Counter=0 " and later say something like “if(Movie1.Coutner % 5 ==0) {…” then this solution will help me identify the problem.
But it doesnt prevent me from implicitly declaring variables, i.e.
in a case where I make the stupid mistake of saying in one place “Movie1.Counter = 0” and another place “Movie1. Coutner++”…it will still juz immediately create a new property Coutner. None of my variables will be undefined (but I’ll have more than what I asked for), and I’ll go crazy trying to find out why nothing is updating…and when you have loads of variables and properties its a nightmare to have to do spellchecking on them all!!!
anyways, its the best solution I got so far, so I will be looking into it, thx…

I can hear some of you saying “juz be careful when typing for f**ks sake!” :slight_smile: but its such a simple and obvious thing to ask for I think!

That’s the way Flash is buit, so
“juz be careful when typing for f**ks sake!” lol,
it’s true this is often very time consuming, and once you find out the reason is a stupid typo,
you’re ready to
a.kill yourself
b.uninstall flash
c.format C:\
d.change jobs
=>please select… :slight_smile:

e. all of the above… :wink:

my only followup suggestion is to take typing courses :stuck_out_tongue: