Import from parent folder?

Monkey Forums/Monkey Programming/Import from parent folder?

Skn3(Posted 2013) [#1]
Lets say I have a module structure:

module/module.monkey
module/import1.monkey
module/folder/import2.monkey

in module.monkey I:
"Import import1"
"Import folder.import2"

in import1.monkey I:
"Import module"

in import2.monkey I:
?


Is there a way to do "Import ..module"?
e.g. import from a parent directory?

I could currently either put all source files in the root folder, or hard code the module path... any better ideas?


MikeHart(Posted 2013) [#2]
Import module does not work? If not, then i guess it is a bug. Or is the module name the same as a class name?


AdamRedwoods(Posted 2013) [#3]
import "../module.monkey"



Skn3(Posted 2013) [#4]
Are you kidding me? Cool thanks will try that :D


ziggy(Posted 2013) [#5]
Import module should work


marksibly(Posted 2013) [#6]
What Ziggy says.

Your app dir is it's own little module hierarchy, so you can reach any module in the app by importing it 'from the top'.

eg:

myapp.monkey 'contains 'Main'.
myutils/util1.monkey
myutils/util2.monkey

util1 can be reached from anywhere in the app using Import myutils.util1.


hardcoal(Posted 2013) [#7]
Had the same issue. tnx


nigelibrown(Posted 2014) [#8]
If I import "native/system.cpp" from my module, how would i access a header file from the system.cpp file? "#include ../../file.h" would include it from my project using the module not the module?