<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Language > Script structure > Pre Parsing directives >





Instruct the interpreter to read a text file from disk and treat it as an integral part of the source code.














When parser encounters an #INCLUDE statement, it reads "FileName" from disk and attach the included file inside main script.  The result is the same as if the contents of the included file were physically present within the main script.  This allows large source files to be broken into smaller "units" that are more manageable.


"FileName" can have a full or relative path. Relative paths are always considered relative to the main script.

If no path is specified, main script path is assumed.


Optional ONCE clause can be specified. If ONCE will be specified, before including "FileName", interpreter will check if "FileName" has already been included. If  yes, "FileName" will not be included again.


Including more than once a file can have impredictable results. If the included file contains user functions or variable declarations, a duplicate symbol runtime error will occur.


The following meta variables are supported inside FileName:




Insert thinBasic installation path


Insert current script path


Insert thinBasic standard include path



















































%CSIDL_* meta statements info: https://msdn.microsoft.com/it-it/library/windows/desktop/bb762494(v=vs.85).aspx


Those meta statements will be resolved using SHGetFolderLocation function  


Meta variables are place holders that will be replaced with relevant values at script run-time.


Optional AS COMMENT clause at the end of #INCLUDE statement instructs pre parser to not use include file in parsing process. This directive is mainly used in case you want to add documentation files.


"FileName" can contains ? or * in order to specify a file mask. This option can be useful when:

more than one files are to be included

dynamically load files present in a directory (plug-in idea)

other dynamic reasons


You can specify the file to be included using a URL via HTTP or HTTPS instead of a local pathname. See example below.




This directive is a pre parsing directive. It means all #INCLUDE statements will be solved before starting script execution.


See also




#INCLUDE ONCE "Config.inc"

#INCLUDE ONCE ".\Includes\DB.inc"

#INCLUDE ONCE ".\Includes\Theme.inc"

#INCLUDE ONCE ".\Includes\Header.inc"

#INCLUDE ONCE ".\Includes\Footer.inc"

#INCLUDE "object_*.tbasic"


#INCLUDE "%CSIDL_LOCAL_APPDATA\MyIncludes\object_*.tbasic"


#INCLUDE ONCE "https://raw.githubusercontent.com/petrSchreiber/uniTest/master/uniTest.tbasicu"