On 27 Sep., 10:17, chris idr <[EMAIL PROTECTED]> wrote:
> HI I am trying to run this code:
> global.currentHangManWord = "a word of any sort";
> var curChar = "";
> curChar = global.currentHangManWord.charAt(pos-1);
> within rhino.
>
> I have added the global object via
> Object globalObj = cx.newObject(scope);
> org.mozilla.javascript.ScriptableObject.putProperty( scope, "global",
> globalObj );
>
> then i call the script code.
> Object result = cx.evaluateString(scope, code, "<javascript>", 1, null);
>
> NOTES: cx is a Context object.
>
> PROBLEM :
> i keep getting this error
> TypeError: Cannot call method "charAt" of undefined (<javascript>#8)
> executing code=
>
> can anyone enlighten me as to what i am doing wrong please?
>
> Kind Regards
>
> Chris Wade
hey chris,
Sounds like your context finds in your scope object (walking down to
find the base) some global property...
that's why it is not registered on top level;
try this instead; if scope is your top level scope, than
scope.put("global", scope, globalObj );
should work that way..
cheers
carlos
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino