Include statements
I would like to use the include statement for a 1000 line program I've built. I'm doing some refactoring and ideally would like to break it into two files. Does anyone have any advice on how to use the Include statement because I am trying to use it to separate out some functions from my main file and get interesting errors. These include
![2009-12-22_2038.png](./2009-12-22_2038.png)
Comments
I'm guessing that the file "fpu.sxb" is one of the included files, and that you're trying to compile it by itself. If so, then the reason you're getting errors is that the compiler needs the declarations made in the main source file. There are two solutions. The first is to always make sure you compile the main program and let it tell the compiler to include the other files. This is a pain because you constantly have to switch active files in the IDE. The other is to use the (sadly, still undocumented) "Top File" feature of the IDE.
Basically, the "Top File" feature was implemented for exactly this situation. You want to have multiple include files, and you also want to be able to hit the compile button while working on any of the them. To do this, you need to tell the IDE which file is the "top" file and then it will do the rest.
Here's what you need to do.
1 - Load whatever file is your "top" file.
2 - Right click in the file list pane on the left side of the IDE.
3 - Left click the menu option that says "Set as Top File"
The attached image shows the menu in operation.
From that point on, any time you hit the compile button (of hotkeys), the IDE will offer to use the "Top" file as the one to compile from. Click "Yes" or hit the Enter key and the IDE will do the rest. The IDE keeps track of your topfiles using the registry. This means that whenever you load a known "Top" file, the IDE will offer to make it the current "Top" file. Note that you can only have one "Top" file open at a time in the IDE. If you ever decide to convert the project back into a single file project, you can right click and choose the menu option that says "Set as normal File."
Thanks,
PeterM
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropBASIC home page www.propbasic.com
·
1 - I take a good chunk of time to explain how to use an un-documented feature and you don't even say, "Thanks." Seriously, how hard is it to type type six letters and acknowledge that someone took time out of their day to help a complete stranger?
2 - It's not an error message. Where does it say "Error" on that dialog? It's a dialog to make sure that people don't forget they have a top file loaded. What if you loaded another project, forgot you still had a top file in the IDE, and then hit "Compile"? If that happened, you'd be be posting that the IDE refuses to compile your program.
3 - I anticipated this question when I wrote my original reply to you, but apparently you skipped over that part of my detailed reply. Here's the relevant portion of the original post - "From that point on, any time you hit the compile button (or hotkeys), the IDE will offer to use the "Top" file as the one to compile from. Click "Yes" or hit the Enter key and the IDE will do the rest."
4 - This concludes my involvement with this thread.
PeterM
Sorry... the forums giving trouble and will not let me upload .sxb files without changing the extension; remove the .txt from the files before use (I've tried two pcs and two different browsers).
· I was able to upload them. Weird ???
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
P.S. -- to PJMonty -- is top file only for INCLUDEs? Or will it work for LOADs also? The original question probably was about LOAD (as the project is SXB) even though the word "include" was used.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Post Edited (Zoot) : 1/8/2010 6:09:39 AM GMT