hello,
main script creates IE window, put an array there and then calls a child
script. chils script makes an array element equal to some object and
returns control to main script. then main script doesn't see that object
and its functions. why?
here is the code I implemented:
//in main script
oWSH = new ActiveXObject(W Script.Shell);
oIEWindow.docum ent.Script.MyAr ray = new Array()
oWSH.Run("child .js", 2, true);
//in child.js script
var MyObj = function() {
var Value = 3.14159;
var getValue = function() { return Value; }
var setValue = function(arg) { Value = arg; }
this.gV = getValue;
this.sV = setValue;
}
oIEWindow.docum ent.Script.MyAr ray[0] = new MyObj();
oIEWindow.docum ent.Script.MyAr ray[0].sV(2.71); // <-- this works
oIEWindow.docum ent.Script.MyAr ray[0].gV(); // <-- this works
//returning back to main
oIEWindow.docum ent.Script.MyAr ray[0].gV() // <-- this doesn't work
is it possible to set an object in array and call its functions from a
child script and then call'em again from main script?
what did I assume wrong in this code?
please help,
regards,
mirek
ps. I also tried the following definition of MyObj with no success:
var MyObj = function() {
mo = new Object();
mo.Value = 3.14159;
mo.gV = function() { return mo.Value; }
mo.sV = function(arg) { mo.Value = arg; }
return mo;
}
main script creates IE window, put an array there and then calls a child
script. chils script makes an array element equal to some object and
returns control to main script. then main script doesn't see that object
and its functions. why?
here is the code I implemented:
//in main script
oWSH = new ActiveXObject(W Script.Shell);
oIEWindow.docum ent.Script.MyAr ray = new Array()
oWSH.Run("child .js", 2, true);
//in child.js script
var MyObj = function() {
var Value = 3.14159;
var getValue = function() { return Value; }
var setValue = function(arg) { Value = arg; }
this.gV = getValue;
this.sV = setValue;
}
oIEWindow.docum ent.Script.MyAr ray[0] = new MyObj();
oIEWindow.docum ent.Script.MyAr ray[0].sV(2.71); // <-- this works
oIEWindow.docum ent.Script.MyAr ray[0].gV(); // <-- this works
//returning back to main
oIEWindow.docum ent.Script.MyAr ray[0].gV() // <-- this doesn't work
is it possible to set an object in array and call its functions from a
child script and then call'em again from main script?
what did I assume wrong in this code?
please help,
regards,
mirek
ps. I also tried the following definition of MyObj with no success:
var MyObj = function() {
mo = new Object();
mo.Value = 3.14159;
mo.gV = function() { return mo.Value; }
mo.sV = function(arg) { mo.Value = arg; }
return mo;
}
Comment