On Sat, 21 Feb 2004 14:09:46 -0500, Jeff Swayze wrote: >Hi Folks, > >Though still very much a beginner at this, I now have several "modules" of >code under my belt, like LCD routines, delay routines, math routines, etc. >Currently I have these stored seperately and use the "#include" statement to >integrate them into the main program. The variables and equates for each >routine are then prepended to the main program's variables at the top of the >code. > >My question is: Is there a defacto standard or any kind of guideline as to >how to manage the variables and equates associated with an include file? >I've seen some examples use ".h" header files that are "#included" along >with their code (ie, LCD.inc and LCD.h) but this seems inefficient. Is there >a way I can include a module's variables within the module itself, thus >avoiding the use of multiple files? > >I'd be curious to hear how others manage these items, and perhaps code >organization in general. I'm certain there's a better way than what I'm >doing now. > While it's certainly not a formalized standard as such, I think many of us (if not most) use relocatable code to organize our source code. This allows the creation of isolated modules that are then linked together to form the application. Any variables that are local to the module are defined within it and only those which need to be accessed by other modules are declared to be global in scope. The same is done with subroutine entry points - local ones are only called from within the module and those that need to be accessed from outside are declared as globals. Switching from working with absolute to relocatable code takes a bit of work and the learning curve can be a bit intimidating but, IMHO, the benefits are well worth the effort. Regards, Bob -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads