Hi mischl,

At last, someone has seen the light.

The BARgraph program was written as an example of that very Idea.

In this thread Making PBP code more modular we've been talking about some of the Pro's and Con's of using Include files.  While others have expressed a different opinion, they did so before I had a chance to say my piece, and offer examples, So I'm not sure if they still feel the same way or not.

But to try to breifly answer your question.

Variables are only declared once. It can be in the main program, or in the include file, it depends on how they are going to be used.  It's best to define any variables required by the include file, In the include file. That way when you include it in a different program, everything is already there.

In effect, when the program gets compiled, it's just one big file. All of the Include files get combined into 1 big program. So, all the same rules apply. You can't duplicate variable names or labels. Constants and macro's must be declared before their use. And, most importantly, the execution of the program cannot accidently fall into a subroutine that isn't gosub'd to.

The last one just means that you have to jump over any code contained in the Include file with a GOTO and a label at the end of the include. Each include must jump over it's own code, but may also contain Initialization code that is not jumped over. This code will only be executed once on power-up. That's great for setting-up variables that need to be a certain way for the include to work.

---------

My mission now is to get everyone to use includes and macro's.
I'm done with the "Blinky lights" and "why doesn't my program work" stuff.
But, I would love to hear more questions on this topic.
<br>