After having tripped for the umpteenth time into seemingly erratically working code because of the same reason, I decided to put this in golden letters (500 pt) above my monitors:
Whenever an application seems to ignore your code, go and check the occurrence of event handlers.
And having done so, I thought maybe some of you would have fun adding to this. Theres probably more than one routine you learned to follow during your discovery of Xojo, so why not share it with others who will follow?
Aren’ event handlers code too?
Sure they are. To clarify:
You instantiate some new element of your code, toss some parameters over to it and it seems to ignore them, working with its default values.
I stumbled a few times about this because some open or activate handler in the new instance started working right away which I didnt realize first because the default values were set to work, well, with the default parameters that work for the trial case, of course. And because I wasnt clear about each call to the events and the order in which they are called.
I know this may seem silly because one should always check for the validity of code for the possible scope of input parameters, but I guess many of us came to learn something the hard way, redoing the same error until one realizes the pattern
So feel free to add
The one that often bit me was global properties in more than one global module. There would wind up being global properties declared in two modules where the properties had the same name. Sometimes I would think I was addressing one while the code thought I was addressing the other. So I finally put up a reminder…
Of course, having unique names also solves the issue but sometimes in inherited code…
Oh! Thats possible? Thanks for sharing, Dale! Learned a new fact!
Seems to me the idea of putting globals on the app. level isnt that bad I was condemning the fact I have done so in several cases initially as I always have to type a bit more but this would surely have been a trap I found myself in else
If you really need to Yield time back to the MainThread (for updating the UI maybe…), use App.DoEvents() only from within a seperate Thread. But better avoid using it anyway…
Better a robust solution than a fragile Ferrari. Keep it simple.
Or just yield to other threads http://documentation.xojo.com/index.php/Application.YieldToNextThread
The thing is… we don’t have a list of those. Sometimes you get an explicit error about this, sometimes you don’t. And it becomes what I call an ‘esoteric’ issue ; - )
To understand recursions you have to understand recursions first
…ah and I forgot to mention: Never forget an exit condition for recursions…