I am creating an include file for a MAX6954 LED display chip. I figure since I might use this alot it would be not only cool to have certain commands etc predefined but to also have certain subroutines reside in the include file as well.

So I have an include file, and at the top I define all my variables used in that file's subroutines only. so it looks something like:


' Include File

' {Define some variables here}

Goto Exit_IncludeFile

'{Define a mess of subroutines here}

Exit_IncludeFile:

So this is all cool and everything but then I get to thinking... I have all these subroutines stored BEFORE my main subroutine... I know back in the days of GWBASIC or TRS-80 Basic that would be a HUGE no no, but that was an "Interpeted" lanquage, where as picbasic is compiled into machine code in the end so it shouldn't matter.... Right? or does it? (thats question #1)


So this whole include file is at the beginning of my code. I figure thats best because I define all my variables first... in the beginning.

But would there be anything wrong with sticking the "include" at the END of my code... more toward the "Subroutine" area? Is there anything wrong with putting all these "Something var Byte" statements up there? The compiler doesnt care as long as its declared before the variable is used... right? (question number 2)

I guess long story short: What is the the "Best" (in your oppinion obviously) to keep an include file that contains both variable definitions and subroutines.


And finnaly... heres one i don't know how to get around the "Easy mindless way".

Even with all my variables declared and my nice little subroutines, I would like to try to keep the whole shabang in one file that can be used in any other program without modification. Unfortunatly, the chip interfaces with the pic through pins... specificaly there is a "Clk", "Din", "Dout", and "CS". So if some of my subroutines use any of these pins in the include file (and they do) then I would have to remember to declare those pins either in the include file or the main program file... If they are declared in the include file, then I would at least know all my subs should work... but then Im stuck with CLK = some pin, Din = something else and every PIC I program with the include file would have to conform to that... so what if I use a different pic? then I have to define those pins in the main program file... leaving the "include" file somewhat incomplete.

I was thinking maybe aliasing but I dont know if/how that works.

I hope this all makes sense to some one... I'll shut up now and go RTFM now 'cause I think im starting to just ramble...