Subj : Question about Scope and context.evaluateString with object member To : netscape.public.mozilla.jseng From : Jihai Qiu Date : Tue Apr 22 2003 01:03 am I am trying to set value to a JS object member using scriptable.put method and then using context.evaluateString to get the value back. But the value is always undefined. I am able to use scriptable.get method to get the value. But without evaluateString method, I am unable to evaluate the expression with the object member. Can someone please check what is wrong here? My test program is based on the RunScript.java file in the examples folder. Here is the snippet. Scriptable scope = cx.initStandardObjects(null); String obj_name = "current_object"; String var_name = obj_name + ".expr"; Scriptable jsArgs = cx.newObject(scope); scope.put(obj_name, scope, jsArgs); scope.put(var_name, scope, "TestValue1"); Object result1 = scope.get(var_name, scope); // Now evaluate the string we've colected. Object result2 = cx.evaluateString(scope, var_name, "", 1, null); // Convert the result to a string and print it. System.err.println(cx.toString(result1)); System.err.println(cx.toString(result2)); // try with eval cx.evaluateString(scope, obj_name + " = new Object()", "", 1, null); scope.put(var_name, scope, "TestValue2"); Object result3 = scope.get(var_name, scope); // Now evaluate the string we've colected. Object result4 = cx.evaluateString(scope, var_name, "", 1, null); // Convert the result to a string and print it. System.err.println(cx.toString(result3)); System.err.println(cx.toString(result4)); The print out is: TestValue1 undefined TestValue2 undefined Thank you very much for your help. Jay Chiu jqiu@broadstrokesinc.com .