This loader is slightly different from all the rest, as the item in the inventory with the ".map" suffix must be a directory. Each item in the directory is autoloaded and entered into the map.
Technically this doesn't load a file, it loads a directory and it's contents.
The most simple example is to create an empty directory in the
inventory, e.g. simple.map. This would create a new map,
with no entries and assign it to a variable called
simple. This would be identical to the following:
var simple = newTreeMap();
This loader becomes really useful when you need a map of strings to different MillScript types, e.g. functions, XML, etc. You could write a large piece of MillScript to achieve the same effect, but the various loaders exist to save that.
A more complex example might have a directory in the inventory called harder.map. In that directory you might create a text file text.txt, a lines file somelines.lines, a template template.tp and a millscript file processtext.ms. Then when using the autoloaded map you would see the following:
| MillScript code | Resulting datatype |
|---|---|
harder["text"] |
string |
harder["somelines"] |
list |
harder["template"] |
template function |
harder["processtext"] |
function |
map, containing all the required entries, as detailed
in the file format. e.g Lets assume you
create a file called test.map.
test