When starting work with DesignBais all of us are introduced to that initial bit of code – the big Case block that does the Gosub to handle each event. Many of us copy this template to all of our programs, then cut out what we don’t need. Some of us leave it all in there, just in case we do want to handle some event later. Well, if you’re going to do that, then you might as well have all of the events defined.
Here’s a new template that has all of the v3.3 events that I know about, and a couple extra helpful variable definitions. I don’t know yet if there are any new v4 events, but if there are I’ll post another version later. I’ve also provided just a couple lines of code samples down at the bottom of the program (what I call the Bone Yard) which I use to remind me of syntax for some common functions. I’m hoping that other people will contribute common code (via email) that they’ve found helpful, and maybe we can use this to build a common template that we can all use. I don’t want to include suggestions for application comments, copyrights, etc – we’ve all been doing this for a while and have our own "best practices". But I’d be very curious to understand how people are using various tricks in all of their DesignBais code, specifically to get the most out of this tool.
This code, originally made available in early DesignBais docs, isn’t intended to tell someone how to do their development, but to serve as a guide until people develop their own style. For example, rather than keeping the HANDLE.EVENT subroutine in mainline code, I’ll sometimes revise the template to put that in an Include block. It’s the same code all the time, so why duplicate it everywhere? This is a matter of taste, so handle it according to your own preferences. Similarly, some people might prefer to have a unique program for every event, rather than one program for all events for a form..
I also use a standard method to assist with debugging. Essentially, I open a file called DB.DEBUG, and wherever it seems like I’ve changed something in code and I need to know what’s happened, I’ll write a new item with a specific structure and a unique ID to that file, and include whatever data seems to be vital. Then I just SORT-ITEM the file to see what happened as the code executed. It’s very helpful when multiple events are firing one right after another. I’ll post that here if anyone is interested. I don’t know if there would be any value to a whole post on code debugging in DesignBais, so I might just post it as a comment or addendum here.
[EDIT] David Norman busted me within hours of posting this to tell me I had missed the Before Screen event. It’s in there now. Thanks David ! This is just the sort of feedback I’m hoping we’ll get.