Syntax
Puts the lines of a BASIC module of the project in place of the line, every time it appears. It is PureBasic's name for #INSERT.
IncludeFile "<path>"
IncludeFile("<path>")Parts
| <path> | The module's name in the project, in double quotes, such as snippets/tick.bas. It is looked up next to the file that holds the line, then from the project root. Case is ignored, of the path and of the word IncludeFile. |
|---|
Good to know
- In the example, the module
snippets/tick.basholds the linecount = count + 1. Inside the loop it is inserted once and runs three times; the secondIncludeFileadds a fourth run. - It looks like a command but it is a directive, settled before compiling. It returns nothing and cannot be used in an expression:
x = IncludeFile("a.bas")is refused withUnknown BASIC command: IncludeFile(). - It behaves exactly like
#INSERT: no once-only rule, a cycle is a compile error, and an unknown path givesBASIC include file not found: <path>. - One per line, alone on it. A trailing
'comment is fine. - PureBasic's
XIncludeFile(include once) is refused withNot a BASIC statement. Write#INCLUDE.
Example
snippets/tick.bas
count = count + 1main.bas
count = 0FOR i = 1 TO 3 IncludeFile "snippets/tick.bas"NEXTIncludeFile("snippets/tick.bas")Console(Str(count)) ' 4In the manual : The preprocessor