Include / Require

The “include” and “require” command lets you embed one script inside another script. This helps make your projects more manageable and speeds up development time as it lets you reuse your code. You can also include LiveCode stacks.

include: Includes the given script each time it is called. Each time it is called it will reset any variables that are set in the included file.

<?lc include "my_settings.lc" ?>

require: Only includes the given script if it has not already been included or required

<?lc require "database_library.lc" ?>

Example 1. The difference between include and require

settings.lc contains the following:

<?lc
put "red" into myVar
?>

Using include

include "settings.lc"
put myVar // outputs "red" as its set in the included file
put "blue" into myVar
put myVar // outputs "blue"
include "lc/settings.lc"
put myVar // outputs "red" as the myVar value