MBS Javascript - Arrays and Registered functions

If I use JavaScript to set a parameter of the function registered as an array,
I can then transfer it to the function in the application. See example below.
This example works !!

'Function Registration
JSObject.RegisterFunction ("TestSetArray", AddressOf JS_SetValues,4, Nil)
Public Function JS_SetValues(Name as String ,Params() as variant,Tag as variant) As variant
Var IntegerValues() as integer
Var TempVariant() as variant
'!!! params(3) contain an array !!!
  TempVariant = Params(3)
  For each Value as variant in TempVariant
end try
'App Sub
Return SetAppvalue(Params(0), Params(1), Params(2), IntegerValues)
end function

But if the application function returns an array, javascript indicates the variable as undefined

'Function Registration
JSObject.RegisterFunction ("TestGetArray", AddressOf JS_GetValues,0, Nil)
Public Function JS_GetValues(Name as String ,Params() as variant,Tag as variant) As variant
Var TestArray() as integer
TestArray() = Array(1, 2, 3, 4, 5)
Return TestArray
end function

How can I do this?

RegisterFunction, so you use JavaScriptEngineMBS class?

Of course !

Thank you for the report.
We’ll implement the missing conversion for arrays to integer for the next pre-release.

1 Like

Thank you Christian !!
It may be more convenient for the function to return a variant array to JavaScript instead of just integer, Boolean,… array?

Note: This is just an observation, and I don’t know the complexity to doing that.