Let me first start with admitting that I am a noob in JavaScript. So the question might not be very sound at the basics and might lack enough information to help me.
Background
My organisation has an internal Eclipse based IDE for JavaScript. All we have to do is write scripts in JavaScript and directly execute them. My guess is it uses Rhino since I have seen it in the stack trace of some exceptions.
My code runs across 3 ".js" files.
Script-1: Declare global variables and instantiate them as Java objects
importClass(java.util.HashMap);
var hmTCResult = new HashMap();
Script-2: Perform some actions using the global variables from Script-1
Script-2.prototype.run = function() {
hmTCResult.put("Result", "Fail");
};
changeStatus = function(strStatus){
hmTCResult.put("Result", strStatus);
};
Script-3: Call function in Script-2 which uses the global variables
changeStatus("Pass")
Problem Definition
When from Script-3 I call the function in Script-2 it doesn't seem pick the instance variables and my function fails i.e. I get an exception "hmTCResult not set to the instance of an object." Please note that the the same variable hmTCResult works well in Script 1.
I have done some reading of the Scope and the Context in JavaScript but haven't been able to break through it, since I don't see it explicitly in the IDE.
I will be happy to provide more information if needed.