« Xojo Workshop in UK | Home | Two months till Xojo.… »

New in the MBS Xojo Plugins 20.0

Last week we introduce the MBS Xojo Plugin in version 20.0. Today I want to give you an overview about what’s new.

JavaScript Engine

Furthermore we offer functions for the use of JavaScript in Xojo solutions. If you have a problem that you want to solve, you don't have to reinvent the wheel again and again. Perhaps someone has already found a solution to this problem and shared his solution on the internet. If the code of the solution is in javascript, you can evaluate the code with the help of the MBS Plugin in your project. You can add and call functions, Set and Get global properties and execute JavaScript code. For example we want to write a function that add a numeric value to a global JavaScript variable the code can look like this. An example:

Dim js As New JavaScriptEngineMBS
Dim r As Integer
js.GlobalProperty("A") = 2
js.AddFunction "AddNumberToVariableA", "function (x) { return A+x; }"
r = js.CallFunction("AddNumberToVariableA", 3)
MsgBox Str(r)

You can use our JavaScriptEngineMBS class just like you would use XojoScript control to define your own scripting language.

Also new is the WKWebviewMBS class for macOS to better use WebKIt 2.x. We can have objects that displays interactive web content, such as for an in-app browser. You can load content and can navigate through it. In the web view you can even execute JavaScript code with the EvaluateJavaScript method.

New functionality for audio

In the newest plugin version we supply a lot of new audio functionality.

We add three classes for the Windows Media Foundation player. With this player you can play audio and video in your applications background under Window. We can create a new instance of the MFPMediaPlayerMBS class with a given file URL. Then the file loads and we can play the audio and/or video, stop it, mute it, pause it, set the speed and the speaker volume. For the video on screen we can set the position and size of the video.

With the Device() function you can query the list of audio devices and check the capabilities for a given audio output device for windows. To example you can list the devices in a popup menu with channel counts:

Dim c As Integer = WindowsPlayerMBS.DeviceCount
For i As Integer = 0 To c-1
    Dim d As WindowsPlayerDeviceMBS = WindowsPlayerMBS.Device(i)

    PopupMenu1.AddRow d.Name + " " + Str(d.Channels)
    PopupMenu1.RowTag(i) = d
Next

But we have some new audio methods that can used by non Windows users. In the plugin we have classes to use the open source PortAudio library in Xojo. For the class PortAudioMBS we get new methods to query informations like input/output channel name or the size of the buffer. Moreover we can display the ASIO control panel for a specified device. With the new methods from the PortAudioStreamBaseMBS class we can set the sample rate of an open ASIO stream. We can get the number of input and output handles used by a PortAudio and then get the individual handles for the WinMME streams by index, so you could use them for Windows API functions directly.

New functions for files

We have three new methods to get informations from files and folders.
With the method “FolderItem.SortedFilesMBS” we get the folderItems as an array. This array can be sorted by the displayed name of the file or the file name. The method “FolderItem.SortedFoldersMBS” does the same with folders instead files. Similar is the “FolderItem.SortedItemsMBS” method that returns all items, folders and files.

The new ImageMagick7 classes

At next I want to present you the ImageMagick 7 classes. With this classes you can use the functionality of the ImageMagick library in version 7 for image editing. You can e.g clip, clone, and blur an image and use a lot more functions and effects to editing your image. Before you can use this classes in your project, please install ImageMagick 7.0.9 on your machine. For your application you can also just include the relevant dylib/dll in the same folder as your application and load it from there.

Two algorithms from the theoretic mathematics that can help you to solve problems

Moreover we added classes to solve a problem from the theoretic mathematics. At first we added the LGLMBS class for the SAT Solver from lingeling. A SAT solver solve the boolean satisfiability problem. The solver determine if a variable assignment exist for a given Boolean formula. This can help to solve many problems that we faced as programmers.

The second classes are to run the Levenberg-Marquardt least squares fitting algorithm. The Leveberg-Marquard algorithem try to solve the best curve fitting problem. To a series of known measurement data, a function should be found the function that fits as well as possible. This makes the prediction of values possible. The programming of this classes in the plugin are based on lmfit library from Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013).

One more thing for Windows - The new functionalities of the HTML Viewer

For Windows we added new classes to better provide functionality for Internet Explorer based HTMLViewer controls. Check out the new IEDocumentMBS and IEWindowMBS classes. Use our new Evaluate function to run JavaScript and get back the result.

Besides the evaluation of JavaScript we can finde text or load the HTML text into the html viewer with the methods from the IEDocumentMBS class. Also new are the classes IEWebBrowserMBS and IEWindowMBS with this classes you can display the WebViewer, set informations for the displaying and position or navigate by code.

Maschine learning for Mac

The CoreML Component provides machine learning functionalities for MacOS 10.15 or higher. With the new version of the MBS Plugin you can update existing models with new training data. If you are interested in this functions please check out the belonging blog entry: Update Machine Learning Model on Device

JSON equal content

We developed a new EqualContent method for the JSONMBS class. With this method you can check if the content of the JSON is considered equal. In comparison to Equals method the new method checks the structure and the values in the single nodes. The Equals method check the type of a value and then the values. Here you see the results of both methods in an example.

Dim j1 As JSONMBS = JSONMBS.NewNumberNode(5)
Dim j2 As JSONMBS = JSONMBS.NewStringNode("5")

If Not j1.Equals(j2) Then
    MsgBox "5 not equal '5' "
Else
    MsgBox "5 equal '5' "
End If

If Not j1.EqualContent(j2) Then
    MsgBox "The content of 5 is not equal to content '5'"
Else
    MsgBox "The content of 5 is equal to content '5'"
End If

This shows 5 and "5" have the equal content, but are not 100% equal as types are different.

New functionalities for the open dialog

Also new are some functionalities for the open dialog. You can query an array with all picked files from the dialog. Similar to the method OpenDialogItemMBS queries the picked items as an array. You can query the name, path and the URL of this items, which allows you to pick items without a file path.

I hope you finde some interesting functionalities for your project. If you need a license of the MBS Xojo Plugin or have questions, please visit our website or contact us. Have a lot of fun with the new functions!
by Stefanie Juchmes The biggest plugin in space...
23 01 20 - 12:58