JavaScriptEngineMBS questions

While kicking the tires on JavaScriptEngineMBS I stumbled upon a few questions.

First, arrays created the following way don’t get returned to Xojo with the expected values.

var a = ['car1', 'car2', 'car3'];
a[100] = 'car100';
a.length; // 101
JSON.stringify(a) // Returns full array
a // Returns [car1,car2,car3,car2]

When evaluating misc code, code that still evaluates as expected, it is common to get a JavaScriptEngineExceptionMBS with message: uncaught: ‘invalid count’ – here is an example.

this // uncaught: 'invalid count'

Other JavaScriptEngineExceptionMBS messages have a hexadecimal escaped form of the message. Is there a handy Xojo function out there to unescape the \xNN strings? (Something more proper than ReplaceAll \x with % and DecodeURLComponent)

foo // uncaught: 'identifier \x27foo\x27 undefined'

Out of curiosity, has anyone exposed network access or IndexedDB/WebSQL<->sqlite to the JavaScriptEngineMBS yet? :slight_smile:

Returning a here gives as string:


or as JSON:


now returning this returns [object global] here.

if you evaluate

'identifier \x27foo\x27 undefined'

you get

identifier 'foo' undefined


Using JavaScript Engine example project.

I see I had MBS version 20.0 installed still, downloading 20.5 now :wink:

I’m still seeing the same behaviors, I am using Evaluate however, not EvaluateToString.

EvaluateToString does extra things to convert to text.
Normal evaluate will try to serialize to JSON to return, which may not work always.

The normal Evaluate is also how and where the exceptions I originally listed are generated. Would you like an example project?

What method(s) are the most correct, native and efficient way to retrieve data from the plugin?