Import all files in a folder?

Monkey Forums/Monkey Programming/Import all files in a folder?

slenkar(Posted 2014) [#1]
The reflection filter allows you to add all files in a folder
so can the import command import all files in a folder?


ImmutableOctet(SKNG)(Posted 2014) [#2]
I don't think so. Reflection uses its own filtering system, whereas the 'Import' keyword works with real module paths.

That being said, the standard way of doing something like this is to make a file with the same name as the folder. Importing the modules in that folder is up to you, though. Monkey will automatically resolve the import of the folder as the file in question. Just make sure the file you want to hold the imports is within the folder. A good example of how this works is the 'mojo' module. This is what a lot of modules do, including a few of my own. Some other examples are the 'brl', 'monkey', and 'trans' modules. The big benefit with this is that you always disclose what you're importing, but the module's creator can describe the standard imports. Once again, the 'brl' module comes to mind. In addition to this system, you can import sub-modules without any other module importing them. For example, if 'brl.filestream' was never imported from 'brl', as long as it exists, we can import it the same way.

This goes back to how Monkey handles module paths. Basically, it's just parsing the module path into a system path. However, a direct "path-string" in Monkey is reserved for native source code (C++, C#, etc).


slenkar(Posted 2014) [#3]
Thanks got it