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.
Warning: error handling is broken in version 21.1 of the MBS Plugin. Please update to 22.2 for a fix.
- 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
- 16 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 InitModules
- 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 Plugin, June 2021 News
- News from the MBS Xojo Plugins Version 21.2
- MonkeyBread Software Releases the MBS Xojo Plugins in version 21.2
- MBS Xojo Plugins, version 21.2pr1
- 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
- Multithreaded JavaScript usage
- New in the MBS Xojo Plugins 20.0
- MonkeyBread Software Releases the MBS Xojo Plugins in version 20.0
Xojo Developer Magazine
- 19.5, pages 92 to 93: JavaScript in Xojo, Running JavaScript in your Xojo apps by Stefanie Juchmes
- 19.4, page 9: News
- 18.3, page 47: Happy Birthday MonkeyBread Software, What is new in the MBS Xojo Plugins by Stefanie Juchmes
- 18.3, page 10: News
Videos
The items on this page are in the following plugins: MBS Tools Plugin.
JavaScriptEngineExceptionMBS - JavaShortArrayMBS
