Blitz3D+ Command Reference

Include filename$

Parameters

filename$ - the .bb file to pull in, as a quoted string; a relative path is resolved from the folder of the file doing the including

Description

Pastes another source file into this one when the program is compiled.

Include "enemies.bb" behaves as though the whole of enemies.bb had been typed at that point. It happens at compile time, so there is no loading and no cost while the game runs - it is purely a way to keep your source in sensible pieces. A typical project has the main loop in one file and Includes for the entity types, the level loader, and the handful of utility functions you reuse between projects.

Relative paths are worked out from the folder of the file containing the Include, not from wherever the program was launched, so a file in a subfolder can Include its own neighbours without knowing where the project sits.

Including the same file twice is harmless: the second Include is quietly ignored, so two of your files can both pull in the same helper without you having to track who got there first.

Put Includes at main-program level. Function, Type, Global, Const and Data can only appear in the main program, so a file containing any of them has to be included from there rather than from inside a function. Remember too that the text lands exactly where the Include line sits: if the file contains statements as well as declarations, they run at that point in your program.

Each file chooses its own Dialect - the setting is not inherited through an Include.

See also: Function, Type, Global, Const, Dialect.

Example

; Include Example
; ---------------

; Include pastes another .bb file into this one at compile time.
; include_example.bb defines the IncludedMessage$() function used below.
Include "include_example.bb"

Print IncludedMessage$()

Print ""
Print "Press any key to close the example"
WaitKey

End

Index