Platforms to show: All Mac Windows Linux Cross-Platform
JavaScriptEngineMBS class
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
class | JavaScript | MBS Tools Plugin | 20.0 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes:
We use DukTape, an embeddable Javascript engine, with a focus on portability and compact footprint.
https://duktape.org
Your own JavaScript engine is useful for:
- Running some snippet of JavaScript code without HTMLViewer.
- Using various JavaScript libraries
- Providing a scripting language to your own application.
- An lightweight alternative to XojoScript.
- Working with JSON data
- Enjoy using regular expressions, unicode text functions, number parsing and formatting with no platform dependencies
MBS Plugin added Input(), Yield() and Print() functions for your convenience.
Yield will pass CPU control to other threads, so background tasks continue to run.
MBS Plugin can convert JavaScript values to variant.
Boolean -> Boolean
Number -> Double
String -> String
Buffer -> MemoryBlock
Pointer -> Ptr
Array -> Variant array
Object -> JSON string
null -> nil
We convert variant to JavaScript:
nil -> null
Int32, Int64, Single, Double, Currency -> Number
Boolean -> Boolean
String, Text, Date -> String
Ptr -> Pointer
all other -> undefined
This class is like XojoScript, but using JavaScript as language.
- 2 events
- 7 properties
- property Handle as Integer
- property MemoryBlocks as Dictionary
- property ObjectCount as Integer
- property StringCount as Integer
- property GlobalMemoryBlock(PropertyName as String) as MemoryBlock
- property GlobalProperty(PropertyName as String) as Variant
- property GlobalPropertyJSON(PropertyName as String) as String
- 15 methods
- method AddFunction(Name as String, JavaScript as String, FileName as String = "")
- method CallFunction(Name as String, ParamArray Params as Variant) as Variant
- method CallFunction(Name as String, Params() as Variant) as Variant
- method CallFunctionMT(Name as String, ParamArray Params as Variant) as Variant
- method CallFunctionMT(Name as String, Params() as Variant) as Variant
- method DateComponentsToTime(date as JavaScriptDateComponentsMBS) as Double
- method Destructor
- method Evaluate(JavaScript as String) as Variant
- method EvaluateMT(JavaScript as String) as Variant
- method EvaluateToString(JavaScript as String) as String
- method LoadFunction(Name as String, Data as Memoryblock) as Boolean
- method Now as Double
- method RegisterFunction(Name as String, theDelegate as JavaScriptEngineDelegateMBS, ArgCount as Integer = -1, tag as Variant = nil)
- method SaveFunction(Name as String) as MemoryBlock
- method TimeToDateComponents(time as Double) as JavaScriptDateComponentsMBS
- delegate JavaScriptEngineDelegateMBS(Name as String, Params() as Variant, tag as Variant) as Variant
This class has no sub classes.
Some examples using this class:
- /Tools/JavaScript/JavaScript AES/JavaScript AES
- /Tools/JavaScript/JavaScript Engine
- /Tools/JavaScript/JavaScript Pixel Editing
- /Tools/JavaScript/LibPhoneNumber/JavaScript LibPhoneNumber
Blog Entries
- MBS Xojo Plugins, version 20.5pr2
- News from the MBS Xojo Plugins Version 20.1
- MonkeyBread Software Releases the MBS Xojo Plugins in version 20.1
- MBS Xojo Plugins, version 20.1pr6
- Multithreaded JavaScript usage
- MBS Xojo Plugins, version 20.1pr5
- Comparing JavaScriptEngineMBS to XojoScript
- MBS Xojo Plugins, version 20.1pr1
- MBS Xojo Plugins, version 19.6pr2
- Our JavaScript engine for Xojo
Xojo Developer Magazine
- 19.2, page 18: Deja Vu, Transitions and Reinventing the Wheel by Marc Zeedar
- 19.1, page 10: News
- 18.3, page 29: Virus Modeling, Simulating the spread of COVID-19 with Xojo by Marc Zeedar
The items on this page are in the following plugins: MBS Tools Plugin.
JavaScriptEngineExceptionMBS - JavaShortArrayMBS

Links
MBS Xojo tutorial videos