Import/Export
Last updated
Last updated
This page describes a new experimental feature added in . In order to use it, CLEO 5 must be installed.
For technical details and specification refer to .
CLEO 5 allows to share reusable code across multiple scripts and projects in a form of modules.
Modules are pre-compiled files that export . Scripts can import them by name and call as regular SCM functions. Modules act as libraries that can be developed independently from scripts consuming them.
To create a module with an exported function, create a new CLEO script with one or multiple functions. To make the function visible outside of the module, add an export
keyword before function definition:
This is an example module with one exported function. Save it as my.txt
and compile to get a my.mod
file.
A module can export multiple functions
Some functions can remain private (not exported)
Modules should not have any code outside of functions.
To use a module in a script, add an import
statement in your code:
Compile this script and run in game to see the result.
function name should match the exported function name. Name is case insensitive.
module path should point to the module file relative to the current script.
To import multiple functions from the same module, separate them with commas:
Imported functions are opaque, which means the compiler currently does not validate if it is called with the correct number of arguments. It is user responsibility to provide a correct number of arguments and also make sure there are enough variables to store the result, if the imported function returns any.