Admitting that I am a JavaScript novice, I must acknowledge that my question might be lacking in clarity and detail.
Background
Within my organization, we use an internal Eclipse-based IDE for JavaScript development. The IDE allows us to write scripts in JavaScript and execute them directly. From what I have observed in stack traces of exceptions, it seems like the IDE uses Rhino.
The code I am working with is spread across 3 ".js" files:
Script-1: Declares global variables and instantiates Java objects
importClass(java.util.HashMap);
var hmTCResult = new HashMap();
Script-2: Performs actions using the global variables defined in Script-1
Script-2.prototype.run = function() {
hmTCResult.put("Result", "Fail");
};
changeStatus = function(strStatus){
hmTCResult.put("Result", strStatus);
};
Script-3: Calls a function from Script-2 which utilizes the global variables
changeStatus("Pass")
Problem Definition
When I call the function from Script-3 that interacts with the global variables in Script-2, it fails to recognize the instance variables and throws an exception stating "hmTCResult not set to the instance of an object." It's important to note that the same variable works perfectly fine within Script-1.
I have tried to understand the concept of Scope and Context in JavaScript by reading up on it, but I haven't been able to find explicit information about these concepts in the IDE. If needed, I can provide additional information for better clarification.