News from the MBS Xojo Plugins Version 24.4

In this article I want to introduce you the new functionalities from the MBS Xojo Plugins in version 24.4.

ZXing

We had zxing classes in our plugins to recognize barcodes for many years. The older zxing library we used got outdated, but there is a successor. The zxing library got branched and we can use the newer versions with a different interface to make new classes and a module for Xojo. Today we are pleased to introduce the three new classes ZXingReaderOptionsMBS, ZXingReaderResultMBS and ZxingRuntimeExceptionMBS, as well as the module ZxingBarcodeMBS.

With this module 18 different types of barcodes including EAN, UPC and QRCodes can be read. We can pass the options as a ZXingReaderOptionsMBS instance in the call. We then receive an instance of the ZXingReaderResultMBS class as a result. This provides us with the required information about the barcode. If there are any exceptions, the ZxingRuntimeExceptionMBS class can help us.

Dim result As ZXingReaderResultMBS = ZxingBarcodeMBS.ReadBarcode(pic, options)
MessageBox result.Text

If you would like more information on this topic, please have a look at our blog article Read barcodes with newer zxing classes

DynaPDF

In DynaPDF we have the method GetInEncryptionInfo in the DynaPDFMBS class. This method retrieves encryption settings of the currently active import file. It returns an instance of the class that contains this information as properties. The class is called DynaPDFEncryptInfoMBS. You are welcome to query the properties Filter, HaveOpenPassword, HaveOwnerPassword, Restrictions, UnsafeOpenPwd and UnsafeOwnerPwd here

We also have the new TestPassword method in the DynaPDFMBS class. The main purpose of the function is to test the file against the owner password if the encryption settings should be changed by the user.

CURL

The CURL topic brings new features again in this version. In the classes CURLMBS, CURLNMBS and CURLSMBS there is a method that you should use when retrieving mails from your server. Use the method DecodeIMAPFolderName to decode folder names from UTF-7 encoding.

// test a few cases
Var t1 As String = "Entw&APw-rfe"
Var t2 As String = "Test&AOk-&-"
Var t3 As String = "~peter/mail/&ZeVnLIqe-/&U,BTFw-"

Var d1 As String = CURLSMBS.DecodeIMAPFolderName(t1)
// shows "Entwürfe"
Var d2 As String = CURLSMBS.DecodeIMAPFolderName(t2)
// shows "Testé&"
Var d3 As String = CURLSMBS.DecodeIMAPFolderName(t3)
// shows "~peter/mail/日本語/台北"

The ClearSharedInstance method from the CURLMultiMBS, CURLNMultiMBS and CURLSMultiMBS classes is also new. It clears the shared instance. This will remove the global reference to the shared instance and thus free belonging object.

Scintilla

We added the new SaveToHTML method to the ScintillaControlMBS and DesktopScintillaControlMBS classes. As the name suggests, it creates an html text with the text and styles from the Scintilla control. We can also pass up to 6 optional parameters to this method.

  • Title: is used for the title attribute in the html
  • tabSize: defines how many spaces to use for a tab character
  • wysiwyg: if true, changes html to look more like on screen
  • tabs: If true, we output tab character instead of space
  • folding: If true, adds JavaScript to allow folding sections
  • onlyStylesUsed: If true will only add CSS styles for the used styles instead of all defined ones
Dim html As String = MyScintillaControl.SaveToHTML(Me.Title, 4, True, True, True)

// write to file on desktop
Dim f As FolderItem = SpecialFolder.Desktop.Child("export.html")
Dim b As BinaryStream = BinaryStream.Create(f, True)
b.Write html
b.Close

// and open in browser
f.open

MongoDB

We have also added two methods to Mongo DB. With Operator_Convert from the MongoCursorMBS class, we can output MongoDB records as JSON. This method queries all following records and return them as a big JSON. This gives you a high level of portability to other applications.

Python

In the last release, we introduced you to the possibility of writing Python code in Xojo as well. In this release, we are adding a very powerful RunFile method to the PythonMBS class. With this method you can now also run Python code as a separate Python file. This helps you to create more complex solutions very clearly and to reuse existing code.

Please use the 24.5pr version of the Python plugin due to a bug fix for Windows.

Tidy

We added two new shared methods to the Tidy section. The Tidy method from the TidyDocumentMBS class runs tidy with options on the given input. We specify the input and the options in the parameters.

Dim html As String = "<title>Test"

Dim optionNames() As String = TidyDocumentMBS.OptionNames
Dim optionNamesText As String = Join(optionNames, EndOfLine)

Dim errorLog As String
Dim output As String
Dim options As New Dictionary

// output as xhtml
'options.Value("output-xhtml") = True

// if you want xml instead of html:
options.Value("output-xml") = True
options.Value("input-xml") = True

Dim r As Integer = TidyDocumentMBS.tidy(html, output, errorLog, options)

Break

To match this, we added another shared method to the class: OptionNames. This allows us to output a list of the available options.

XL

We would also like to introduce you to two new functions from the LibXL area. With the new RemovePrinterSettings method from the XLBookMBS class, you can remove the preset printer settings for an Excel workbook. You can also use the method BookRemoveVBA to remove the VBA scripts, also known as macros, from an Excel file. If there are printer settings or macros that have been removed by the methods, the associated method returns a 1.

New Properties for SNMP

We have also added a few new properties in our network area. The class NetSNMPMBS, that performs a SNMP GET query, get the new properties AuthProtocol, Password, SecurityName, SecurityLevel and Version.

Dim s As New NetSNMPMBS

// setup login via SMNPv3
s.AuthProtocol = s.AuthProtocolHMACMD5
s.SecurityName = "username"
s.Password = "test"
s.SecurityLevel = s.SecurityLevelAuthPriv
s.Version = s.Version3

This allows to use SMNP in version 2 and 3.

New functionalities for MacOS

The MBS Xojo Plugins in version 24.4 offers some more new features for Mac users

Handoff

We added a new topic to our plugin: Handoff. Use Handoff to continue tasks on your other devices with macOS or iOS. This section comes with two classes. With the NSUserActivityMBS class we represent an object that provides a lightweight way to capture the state of your app and put it to use later. Create this object to capture information about what a person was doing, such as viewing app content, editing a document, viewing a web page, or watching a video. When the system launches your app and an activity object is available, your app can use the information in that object to restore itself to an appropriate state. Spotlight uses these objects to improve search results for people.

We have the NSUserActivityEventsMBS class to accommodate this. We use this class to catch various events for user activity. Please check the example project to see how we use these classes.

NSView

We now have a hit test for the NSView that you can use. In the parameters x and y you can specify a point to be checked. The method then returns the farthest descendant of the view in the view hierarchy (including itself) that contains a specified point, or nil if that point lies completely outside the view.

NSStatusItem

Do you already know our StatusItem section? With the class NSStatusItemMBS we offer a class to handle a NSStatusitem which is a tiny little item in the menubar. With the innovations in this area, three new events are being introduced. The event DidResize raised when the statusitem resizes. If the statusitem is moved, the event DidMove fires. If the statusitem is shown/hidden due to limited space in menubar the event DidChangeOcclusionState is called.

If you want to know where the status item is located, request the property frame. This then returns an NSRectMBS object that gives you information on size and position.

NSAttributedString

We added two methods to the NSAttributedStringMBS class. The method boundingRectWithSize returns a rectangle whose size component indicates the width and height required to draw the entire contents of the string.

We added the size method from the same class. It gives us the minimum size required to draw the entire contents of the string.

You can use these methods to compute the space required to draw a string.

We hope you will find some interesting new features. We wish you a lot of fun with MBS Xojo Plugins version 24.4. If you have any Ideas for new cool features, need a license or have any questions, please contact us…

4 Likes