« Seven months till XDC… | Home | Xojo checks self for … »

News from the MBS Xojo Plugins Version 21.1

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

BiggerNumber and BigNumber
With BigNumber you can already process very large numbers with a high accuracy, but for some applications it can be important to have an even higher accuracy and therefore we have now BiggerNumber too. Objects of the BiggerNumberMBS class can have a floating point number with 2560 bits. They have a precision up to 617 digits behind the decimal point. Compared to a normal double value we have 5 times as many bits available. If BiggerNumberMBS is so accurate, why would you need BigNumberMBS class at all?
The answer is, if the speed of your applications is more important to you than the accuracy, use BigNumber, but if you need high accuracy, use BiggerNumber. If you use large integer numbers, use LargeNumberMBS. This class provides integer numbers up to 1200 digits long. With the innovation of BiggerNumberMBS also some mathematical formulas are added, like the calculation of cosines, sinus and tangent. There are over 30 new methods available for BiggerNumberMBS and BigNumberMBS classes.

We have some new functionalities for SQL. I have the pleasure to introduce two new methods SQLSelectAsRowSetMT and SQLSelectAsRowSet from the SQLConnectionMBS class. They work very similar. The methods execute a SQL command and return the result as RowSet object. Internally they create a SQLCommandMBS with the given command and call Execute. The difference between this both methods is that SQLSelectMT performed on a preemptive thread, so it does not block the application and can yield time to other Xojo threads. It must be called in a Xojo thread to enjoy the benefits. If it was called in main thread, the main thread will be blocked, but the other background threads keep running.

With the FindTableName method from the SQLGlobalsMBS class, we can query the table name, that we used in a SQL SELECT statement. Our example
Dim sql As String = "SELECT First, Last FROM MyTable WHERE ID = 1"
Dim TableName As String = SQLGlobalsMBS.FindTableName(sql)

returns MyTable because it is the source table.

Also new in this class is the UnInitialize method. It is shutdown the SQL engine explicitly. You can call it if you close the App or use it with the destructor. For the use it is necessary to destroy all connections like for example all SQLDatabaseMBS and SQLConnectionMBS objects.

Finally we got support for edit and update to RecordSet class.

We have also a new property for the CURLMBS, CURLNMBS and the CURLSMBS class. In the OptionAWSSigV4 property we can set a string that makes AWS V4 signature authentication on HTTP(S) header providable. The string is the collection of specific arguments that are used for creating outgoing authentication headers.

A Second block of properties from this topic are the property hyperVersion from the classes CURLSVersionMBS, CURLVersionMBS and CURLNVersionMBS. In this property you see the Human readable string of a used hyper library.

We have a brand new topic area: DuckDB.
The classes from this section provide you functionality of the DuckDB engine. DuckDB is an open source database engine similar to SQLite, but with column based data storage (instead of row based like SQLite). Depending on what you do with the database, this implementation may be much faster since it is optimized to quickly walk over values in a column. Check the new DuckDatabaseMBS class. DuckDB will evolve and we may enhance the plugin classes in further releases.

For the JSONMBS class we have a few new properties. You can read the properties and can find out whether the JSON Object has a special datatype. For example you can read the property IsNumber if you want to know wether the object is a numeric value. The property will return true for numbers or false for other types like text. In the same way you can use the new properties IsArray, IsBoolean, IsNull and IsObject.

For the DynaPDFImageMBS class we have also new properties that’s helps us with the color setting and the handling of Images in a PDF Document. In the property FillColor, you can define the current fill color, that is used for drawing. In the property FillColorSpace you can set the color space in which the fill color should be interpreted.

In the ImageIndex property we can read which index our image has in the PDF working environment. We can then pass this index to multiple methods. From the property ImageHandle we can read the image handler if known.

We have two new methods for GMImage. With the GMImage.IsLoggingEnabled method we can check if the login of events is active. With the SetLogEventMask method we can decide which events are logged. You can define this events in the parameters as a string separated by comma.

By default the logging goes to stderr. In this way on macOS you may need to run your app via Terminal to see logs there.

It is also possible to disable logging. In this case we simply enter a „none“ in the parameters.

New functionalities for Apple users

The MBS Xojo Plugins in version 21.1 offers also some new features for Apple users.

The new NSNetServiceMBS class and the NSNetServiceBrowserMBS class use multicast DNS to convey information about network services to and from your application. The API of NSNetServiceMBS provides a convenient way to publish the services offered by your application and to resolve the socket address for a service. The types of services you access by using NSNetServiceMBS, are the same types that you access directly by using TCPSockets. For example your local web server may advertise HTTP services, which you could look for. Applications can also define their own custom services to provide specific data to clients and use their own service names.

The NSNetServiceBrowserMBS class provides network service browser that finds published services on a network using multicast DNS. Each network service browser performs one search at a time, so if you want to perform multiple simultaneous searches, you need to use multiple network service browsers. A network service browser performs all searches asynchronously by using the current run loop to execute the search in the background. The results from the search are returned through the associated delegate object, which your client application must provide.

Memory Statistics
We have the new class MemoryStatisticsMBS. With this class we can get information about the allocated memory. From the properties we can read information like the number of free bytes, the number of used bytes or the number of total bytes. The result is then logged for example.
System.DebugLog Str(m.bytesFree)+" free, "+Str(m.bytesTotal)+" total"

Data Detection
The new class NSDataDetectorMBS offers you some new possibilities. It analyzes text for data with a special regular expression. The text is scanned for terms of daily use. So dates, addresses, links, phone numbers and transit information can be recognized.

In this example you can see, how you can use this data detection for links and Mail addresses.
At first we define the type of date we want to detect in the text. In this example Links. Mail addresses belongs to the type links. We define an NSErrorMBS object to cache possible errors. We pass the Type and error object to the Data detector Constructor. With the method matches, we search in the text, that we pass in the parameters, for links. The results is saved in an array. In the property URL in one of this result objects, we then found the URL that was detected.
Dim types As Integer = NSTextCheckingResultMBS.NSTextCheckingTypeLink
Dim Error As NSErrorMBS
Dim DataDetector As New NSDataDetectorMBS(types, error)

Dim s As String = "Email us at john@mbs.test today!"

// look for the links now
Dim m() As NSTextCheckingResultMBS = DataDetector.matches(s, 0)

// show first link
Dim r As NSTextCheckingResultMBS = m(0)
MsgBox r.URL

We have some new interesting functionalities for the PDFKit. At first we start with the PDFDocumentMBS functionalities. With the method beginFindStrings you search in a document for strings. In contrast to beginFindString we can enter an array of strings to search for.
Also we can query the attributes of the Author, the creation date, the creator, the producer, the subject and the title. In addition we have methods that display notifications like „string match is found“ in a document or a notification that writes "operation finishes working" on a document.

For the PDFPageMBS class we have the new thumbnailOfSize method. The method returns an image of the page that is define by the object, with the size that we define in the parameters.

The PDFViewControlMBS control has some new events with which you can work in your applications. We have the new mouse events: CocoaMouseDown, CocoaMouseDrag and CocoaMouseUp. All of them fires before the regular mouse events. And work in combination with the control. For example the CocoaMouseDown fires only if the Mouse was clicked in the PDFViewControlMBS control.

Additionally we get more interesting events like: PerformFind, PerformGoToPage, PerformPrint, PrintJobTitle as String (fires when we overrides the job title), WillChangeScaleFactor and WillClickOnLink.

For the PDFViewMBS class we have also interesting methods. With the areaOfInterestForPoint method we can determine the type of the area that is currently under the mouse (as example).
The setHighlightedSelections method sets a highlighted selection. This selection behaves differently from a user selection, because when we click in another area, this area is not deselected. You have to deselect it explicitly. To deselect it, set the selection to nil.

We have over 200 new methods and properties to work with annotations. As a representative, I would like to introduce just a few here from the PDFAnnotationMBS class. The setChoices method make it possible to set choices as array. The choices are an array of strings that are indicating the options in either a list or pop-up menu. The setValue method allows us to set a key-value pair in an annotation dictionary. The key must be valid for the PDF annotation's object type, and must have a value that is acceptable for the key type.
If you want to query the line style for a given name the lineStyleFromName method can be used. In the opposite you can use nameForLineStyle to query the name for a line style.

New functionalities for Windows users

Last but not least I want to introduce the new functionalities for Windows users.

Direct Show
Some of the innovations can be found in the DirectShow section, which is for video recording on Windows. The method AMVideoControl from the DirectShowBaseFilterMBS class queries the video controls for this filter.

In the DirectShowCaptureGraphBuilderMBS class we get the new method FindPin that retrieves a particular pin on a filter, or determines whether a given pin matches the specified criteria. In the parameters we set the pin direction, so we can set if it is an input or an output pin. As result of the method we get a pin object. Typically, an application will not need to use this method. It is provided for unusually complex tasks, when the RenderStream method cannot build the filter graph. Use this method to retrieve a desired pin from a capture filter, and then build the rest of the graph manually.

Also new in this class is the GetStreamConfig method. It queries the stream config object for its graph. An example can look like this:
dim graph as DirectShowCaptureGraphBuilderMBS // your graph
dim filter as DirectShowBaseFilterMBS // your filter

dim StreamConfig as DirectShowAMStreamConfigMBS
StreamConfig = g.GetStreamConfig(DirectShowPinMBS.PIN_CATEGORY_STILL, filter)

We have our graph and our filter and can then set in the parameters of GetStreamConfig the category of the pin. You find the possible categories in the PinMBS class as shared methods.

For the DirectShowGUIDMBS class we have a method that can work contrary: The Operator method. The first direction is that it converts a GUID to a text. For this we set nothing in the parameters. The other direction is that it converts a text to a GUID. For this we set in the parameters the text that should convert to the GUID. The method raises an exception if the text has the wrong format.

WebView 2
For the WebView2ControlMBS class we have two new methods. Th method HTMLText gives us the HTML Text of the current Website. If you want the website Text as plain text you can use the second new method PlainText.
dim web as WebView2ControlMBS // your control

dim text as string = web.plaintext
dim html as string = web.HTMLText

We hope you will also find some interesting new features. We wish you a lot of fun with MBS Xojo Plugins version 21.1. If you need a license or have any questions, please contact us. The biggest plugin in space...
16 03 21 - 13:59