Ok, as I am now starting to lay down some Code, new questions arise. I am not going to start to try and create a serious application just yet; I am getting a feel for how to lay out a standard structure to any Projects I create.
In this respect, I have an issue with the #include Statement. I like the principle of controlling all Logic from Code.
Why is it there at all? As I understand it, it is used to 'include' another .dba file in the Project (I know that sounds like stating the bleedin' obvious, but bear with me...).
Now, the .dbproj File seems to include other .dba Files used in the Project automatically. I say seems, because that is my experience so far, but there may be issues that I am yet unaware of? I have even edited the .dbproj file manually and removed the include references, but when after saving/compiling, they are all back there again.
Hence my question, what's the point of #include Statements?
Furthermore, when I tried to run some Logic, the compiler told me to "**** off" (in Compiler speak
) when I tried this:
Main File:
------------------------
#include "inc.dba"
MyFunction()
------------------------
Included File (inc.dba):
------------------------
Function MyFunction()
Print "Blah blah blah"
EndFunction
------------------------
Now, if I remove the #include "inc.dba", the program runs just fine!
As if this wasn't enough, I tried the same thing with subroutines:
Main File:
------------------------
#include "sub.dba"
GOSUB MySubRoutine
------------------------
Included File (sub.dba):
------------------------
MySubRoutine:
Print "Blah Blah Blah"
RETURN
------------------------
This works whether I have the #include Statement or not!
But... when I try to use an included file with DATA, and try and READ it from the Main File, it compiles and runs without error, but nothing actually displays. Tried this:
Main File:
------------------------
#include "data.dba"
READ A$,B$,C$,D$,E$
Print A$,B$,C$,D$,E$
------------------------
Included File (data.dba)
------------------------
DATA "1","2","3","4","5"
------------------------
Whether I have the #include Statement or not, nothing prints to the screen at all.
I get the same if I do the same with a declaration:
Main File:
------------------------
#include "init.dba"
Print A$
Print B$
------------------------
Included File (init.dba):
------------------------
A$ = "Blah"
B$ = "Yadder"
------------------------
So is there a ruleset/reference that can tell me what does and doesn't work when it comes to the use of included file and/or #include?
I really like the idea of using included files as a means to structure modularly, and seems to me to be a useful way to handle big programs (which some of mine will become if I ever get that far).
Or have I missed something? (very possibly. I have only been dabbling with DBPro for a few days now...)
My objective was a structure along these lines:
#include "init.dba"
#include "data.dba"
#include "sub.dba"
#include "func.dba"
...Program Logic...
and even extend the use of included files if the weight of Code became very large or specific routine were needed, ie.
#include "menu.dba"
#include "DrawWorld.dba"
#include "RemindMeToMakeACupOfCoffee.dba"
and so on, so the structure begins to tak ehte form of a top down, hierarchical structure, with a simple Control Program at the Top, controlling Segments of Code (in their own Structures) as needed.
FOr those that have stuck with this so far, thank!