Global and scope problem

Monkey Forums/Monkey Programming/Global and scope problem

Hima(Posted 2011) [#1]
Can someone please explain me more about the scope of modules? It's kinda confusing to me. I ran into error like this

Compile Error\n\nDuplicate identifier 'Graphic' found in module 'graphic' and module 'graphic'.


or something similar so many times.

Also, it seems like when different modules try to access the global variable from one module, the value they get are different. When I try to access an object from module A, there is no problem. But when I try to access from B, it says the object is null.


degac(Posted 2011) [#2]
See here http://www.monkeycoder.co.nz/Community/posts.php?topic=297#1971

You need to specify the 'correct' name space.


Hima(Posted 2011) [#3]
But there is only one graphic folder...and the error show the same folder as having found in both. So I don't know which one is correct when both are correct. :(

Anyway, for some reasons that problem is gone. But now I have a problem that when different module access the same module, but get different result. Is this due to scope problem too?

I think there might be some problems regarding the Private import. Everytime I use it, it always give me weird errors. For example, overridding a non-existed method, but the method is clearly there. Or can't find an overload method etc. It's like if you use Private import, the inheritance doesn't work properly or something :S

And if I use public import and if a circular import occur, I can't build to android target because Monkey create a code with a duplicate class.


Hima(Posted 2011) [#4]
Surprisingly, the exact same code build just fine without duplicate found or cannot find overload error when I build on Windows.

I've uploaded the whole project. Please take a look and see if I did something wrong or I misunderstand something.

[url]http://hima.gptouch.com/testbed/TestSaru.7z[/url]


JIM(Posted 2011) [#5]
I didn't look at the project, but I ran into similar problems.

I solved them by making sure I include everything only once. Main file includes a ton of files. None of those files imports anything.

Monkey boasts to be able to fix this, but it seems to partially work.


Hima(Posted 2011) [#6]
@JIM
Hmmm I tried but it doesn't work for me. Some of the modules need to make use of other modules :(

Now everything compile just fine, but if I refer to the module as engine.SomeVariable , then that variable is 0 but if I refer to it through other module, like entity.engine.SomeVariable, then that variable is the correct one that I've initialized before.

And when I build for target, I got so many duplicate class errors. I'd guess that it's because of import that mess up the translation to Java somehow. Can someone please confirm this?