Unable to compile programs with 'Include's!

Blitz3D Forums/Blitz3D Programming/Unable to compile programs with 'Include's!

puki(Posted 2010) [#1]
What's going on here?


_PJ_(Posted 2010) [#2]
Include CANNOT work with variables since included files are added before the declarations of any variable information. Even constants wont work.

Any duplicate functions, labels etc. will prevent compilation, as would any oither typical error in an include.

Personally, I find using IDEal and being able to combine all the dependancy files into a project is great for ensuring the references and declarationw exist and don't conflict.


Serpent(Posted 2010) [#3]
This goes back a long while - I found out what was going wrong and I think I deleted my post. It would take me a long while to explain why I was having the problem but it was to with generating data statements (using a program) to include large amounts of data in my exes.


steve_ancell(Posted 2010) [#4]
Malice (Posted 2 weeks ago) #2
Include CANNOT work with variables since included files are added before the declarations of any variable information. Even constants wont work.

Any duplicate functions, labels etc. will prevent compilation, as would any oither typical error in an include.

Personally, I find using IDEal and being able to combine all the dependancy files into a project is great for ensuring the references and declarationw exist and don't conflict.


It does work !, just make sure you do your game code (loops etc) after the included stuff.

I just tested this example and compiled it, and it works.

Example:
;Save this out as main.bb

Include "includefile.bb"

;It works with functions...
DoSomething()

;And it works directly !...
Print constant
Print a
Print b
Print c

WaitKey()
End


;Save this out as includefile.bb

Const constant = 123

Global a = 100
Global b = 155
Global c = (a + b)

Function DoSomething()
	Print constant
	Print c
End Function



steve_ancell(Posted 2010) [#5]
I even just tried it with a non-global, and that also worked !


Yasha(Posted 2010) [#6]
Malice was talking about conditional compilation, not what your example demonstrates. I wouldn't worry about it.


_PJ_(Posted 2010) [#7]
Yes. I meant that you cannot do:

a$="includefile.bb"
Include a$


The fact that the example by steve_ancell works is precisely due to what I was saying, that the included content is compiled prior to the variable declarations or functions.


steve_ancell(Posted 2010) [#8]
@ Malice...

Oh, I see. You're right !