Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: An example to share vb6 script control vs clearscript

0
0
nope assigning an object to a createdobject or assigning a new object to the object passed in does not work for me.
        V8ScriptEngine V8JS = new V8ScriptEngine("FRED");

        string newCode = @" 

var TEST1;

function setTEST1(inval)
{
    TEST1 = inval;
}

function addtoTEST1A(inval)
{
   TEST1.A += inval;
}
";
        V8JS.Execute(newCode);

        V8test T1 = new V8test();
        T1.A = 3000;
        T1.B = 4000;
        V8JS.AddHostObject("TEST1", T1);

        V8JS.Script.TEST1.A += 5000;

        // T1.A and V8JS.Script.TEST1.A are same object, value 8000

        V8test T2 = new V8test();
        T2.A = 1000;
        T2.B = 2000;
        // does not work
        V8JS.Script.TEST1 = T2;
        // does not work either
        T1 = T2;

        V8JS.Script.addtoTEST1A(2000);

        // V8JS.Script.TEST1.A = 10000
        // T1.A = 10000
        // T2.A = 1000
        // ergo V8JS.Script.TEST1 = T2 does not work
        int a = 0;
    }

    public class V8test
    {

        public int A = 0;
        public int B = 0;

    }

Viewing all articles
Browse latest Browse all 2297