Include Question
Blitz3D Forums/Blitz3D Beginners Area/Include Question
| ||
When I try to do an Include statement on another .bb file I'm running into a weird issue that I can't seem to understand. First I try this: Graphics3D 800,600,0,2 SetBuffer BackBuffer() Include "filename.bb" Print "Hit mouse to exit..." WaitMouse End It works perfect. But if I make the filename a global string variable, the compiler spits out an error saying it's expecting a file. When I look at the debug it shows that the string is "" empty... but somehow I'm able to print the variable name (if i comment out the include line) Graphics3D 800,600,0,2 SetBuffer BackBuffer() Global IncludeFile$ = "filename.bb" Print IncludeFile$ Include IncludeFile$ WaitMouse End I don't understand why it won't work.. even if I use full, complete paths etc. Anyone else have this issue or can explain my fault? |
| ||
Why would you want to use a variable to declare which 'include' file to include - once the program is compiled as an executable you won't be able to access different 'includes' by changing the filename. |
| ||
Thanks for the response, Matty. It's a hypothetical scenario. Lets say that I have a folder full of include files containing various functions in a central location. Let's also say that i don't feel like I should have to type out the full path each time, so I'd rather use the absolute path as a variable. Here's an example for you: Const IncludePath$ = "C:\Game Programs\Blitz Basic\My Programs\Utilities\Include Files\" include IncludePath$ + "fileFunctions.bb" include IncludePath$ + "playerTypes.bb" etc... It's not absolutely necessary to need this... I COULD write out the entire path each time... but the point is (as well as the question), if the Include function takes a string as an argument, then why can't I feed it a string variable? |
| ||
Because include is a compiler directive and not a program statement. As such, it is evaluated at compile-time, not runtime. |
| ||
Thought you can use a constant? (Isn't a constant evaluated at compile-time too?) |
| ||
All of your constants are converted to the actual value at compile time so it might work depending on if the constants are converted before the include code is incorporated.that being said I would think it would include the code before converting constants. Whynot use .decl to access the functions |
| ||
I would think it would include the code before converting constants. I'd imagine so, too. Include is actually a pre-processor command where the source is formatted ready for compilation. |