Hello!
I am just getting started with ClearScript but I am finding some weird behavior when it comes to passing .Net objects (strings, integers) into scripts and then using them to return new values.
To be more clear when I load the engine my script is executed and it runs a few functions and fills up an array I am calling Chunks[].
Later on, I want to access the Chunks[] array in a few function, here is a slimmed down, modified version of it.
If I call it like this, however, it returns as undefined.
Thanks for all the work on this library!
JC
I am just getting started with ClearScript but I am finding some weird behavior when it comes to passing .Net objects (strings, integers) into scripts and then using them to return new values.
To be more clear when I load the engine my script is executed and it runs a few functions and fills up an array I am calling Chunks[].
Later on, I want to access the Chunks[] array in a few function, here is a slimmed down, modified version of it.
function getChunk(num) {
return Chunk[num];
}
That section of code returns fine if I call it like this: j = engine.Evaluate("getChunk(" & chunkNum & ")")
Please note that chunkNum is a long value which is equal to 1 in my tests.If I call it like this, however, it returns as undefined.
j = engine.Script.getChunk(chunkNum)
To conclude, the above code works if I alter the javascript function to assign num to another value (n for example) and then return the chunk based on the index of n.function getChunk(num) {
n = num;
return Chunk[n];
}
This makes absolutely no sense to me. It "works" but some explanation of how the different ways to pass parameters work would be awesome.Thanks for all the work on this library!
JC