Trouble including a file in SX/B
Hi, I am trying to split my SX/B program into a couple of files to make things modular. For example, I want to put all my LCD routines into their own file so I can re-use them. For the LCD routines, I have one file that has constant and variable definitions and another file that has the subroutines.
I am trying to include the file with the constant and variable defs right after the device section in my main file. I am using LOAD "header.sxb' but I keep getting an error saying "header.sxb NO PROGRAM COMMAND USED".
Can someone help me figure out what I am doing wrong? Why would I need a PROGRAM command in a header file?
Thanks,
Scott
I am trying to include the file with the constant and variable defs right after the device section in my main file. I am using LOAD "header.sxb' but I keep getting an error saying "header.sxb NO PROGRAM COMMAND USED".
Can someone help me figure out what I am doing wrong? Why would I need a PROGRAM command in a header file?
Thanks,
Scott
Comments
· The compiler is complaining that you haven't used the "PROGRAM label" command in your program.
· If you could post the files we could assist you further.
[noparse][[/noparse]edit] Are you trying to compile "header.sxb" ? That will give you the error. Just make a little test program that uses LOAD "header.sxb" to test the file.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
Post Edited (Bean (Hitt Consulting)) : 6/6/2007 1:29:26 PM GMT
I have attached some test files that demonstrate the problem.
The file "test.sxb" is my original file. This compiles with no errors.
The file "test_new.sxb" is the same file but with some of the constants moved to another file "header.inc". I am trying to LOAD this file in the same location where the constants
originally were and I get the error.
Any help would be greatly appreciated! It appears the pre-processor is interpreting the header.inc file assuming it is a complete program instead of a piece of the whole.
Thanks,
Scott
It looks like it might be a bug in the compiler. I see what's going on, it includes the header.inc file, but the compiler checks at the end of compiling to make sure you have used the PROGRAM directive. It looks like it is performing that check when you "LOAD" a file (and it shouldn't). I will look into it deeper as soon as I can.
If you can re-arrange your program so the PROGRAM directive comes before the LOAD directive, that should fix it for now.
[noparse][[/noparse]Edit] I have verified that the compiler is in fact checking if a PROGRAM directive has been used after compiling the header.inc file. This will be corrected in the next release.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
Post Edited (Bean (Hitt Consulting)) : 6/6/2007 5:50:53 PM GMT
-Scott
What my experiment counts on, however, is a consistent set of variables for subroutines and functions, and I document these requirements in my external files.
I hope this helps.
I wanted to keep things such as IO Pins, Constants, Variables and my ISR in separate files. All of these typically come before the PROGRAM directive. I was able to accomplish this by chaining these files together. So my main program loads the first file, which for me happens to hold my I/O pin definitions. The first file then loads the second file, which for me holds the definitions for all of my constants. At the end of this file it loads the next one which holds variables. And so on. The trick is that the last one to be loaded in this fashion needs to include the PROGRAM directive!
After the PROGRAM directive is encountered you no longer need to chain your files.
I am glad to read this will be improved in the next version. I have done it so often I do not give it much thought anymore!
- Sparks
Sorry I didn't realize the nature of the problem in your old post.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
I only saw it as a problem with me understanding how things needed to be organized to get them to work the way *I* wanted to structure my programs!
- Sparks
-Scott