When the MillScript compiler encounters an undeclared global variable it automatically attempts to load a matching inventory item. This process is called autoloading, which is short for automatic loading. If there are no inventory items of the same name (excluding file extension, of course) the autoloading fails and an error is reported.
The file name extension, by which I mean the bit that follows the last full-stop in the file name, is used to determine the content type of the file.
var image = newList();
image.addLast( { 0xFFFF, 0xA000, 0x0000 } ); # RGB values
image.addLast( { 0xFFFF, 0xA000, 0x0080 } );
image.addLast( { 0xFFFF, 0xA000, 0x0100 } );
... and so on for another 100000 lines
The autoloadable files are put into inventory
directories. There is a single shared inventory
${millscript}/inventory and a local inventory for each web
site ${millscript}/websites/*/inventory. Both the local
inventory and shared inventory are searched, in that order, for a
matching filename.
Autoloadable package have their own structure. To write a package
openworld.tools, for example, you would create a directory
called ${millscript}/inventory/openworld_tools.pkg. Note
how the full-stops are replaced by underbars. In this directory, the
package loader will look for a file with a matching name i.e.
${millscript}/inventory/openworld_tools.pkg/openworld_tools.ms.
When the MillScript interpreter imports this package it unconditionally
loads this file.
Furthermore package directories can have their own autoloadable
inventories. In our example, the package loader would check for
${millscript}/inventory/openworld_tools.pkg/inventory. If
this inventory directory exists it is used whenever trying to autoload
the variables of that package.
Autoloadable Maps are represented as directories, too. Let us suppose we had a collection of images we wanted to make available as a Map from strings to Image objects. All we have to do is give the directory with a ".map" suffix and it will be recognized by the Map loader. Each of the files in the ".map" folder will be autoloaded and their results installed in the Map.