include
include
Function
Import and execute BT files during runtime, and return the explicit return or exit values of the imported files.
Syntax
include(path) include path
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| path | String | Yes | None | The path of the BT file to be imported. |
Return value
| Type | Description |
|---|---|
| Any/Empty | The corresponding value is returned when the include file is executed to return or exit; Empty is returned at the end of normal execution. |
Example
fs('include-demo.bt').write('return 7') result = include('include-demo.bt') // Output: 7 print result include 'include-demo.bt'
Notes
- The path is parsed according to the current source code directory and project root rules.
- The include file will be compiled and cached, but the target file will be executed every time it is called.
- Function declaration will enter the current VM global environment.
- Bracketless syntax only supports statement form; please use
include(path)when you need to assign the return value to a variable.