News from the MBS Xojo Plugins Version 24.0
In this article I want to introduce you the new functionalities from the MBS Xojo Plugins in version 24.0.
Randomness Decides
We have three new global methods that deal with randomness. We provide you with three algorithms with which you can generate random numbers. You can choose from the normal distribution, exponential distribution and poisson distribution. You can also specify the mean or lambda in each method to further influence the method. RandomNormalDistributionMBS then returns random numbers according to the Normal (or Gaussian) random number distribution. RandomExponentialDistributionMBS a random non-negative floating-point number, distributed according to probability density algorithm and RandomPoissonDistributionMBS gives you a non-negative integer value, distributed according to discrete probability algorithm
Arrays
The new SortMBS module provides us with many useful functionalities for arrays. With this module you can copy, compare and sort arrays. Just have a look at the module to see if there is something for you.
Big, Bigger and Large Number
Let's move on to a completely new class in the plugin: BigNumberConversionMBS. This class holds information to convert numbers to/from text. For example, you can select whether you want the comma in the European notation with " , " or in the American notation with " . ". This and much more is possible with the new class. In order to be able to use the class properly, we have added GetStringValue and SetStringValue methods in the BigNumberMBS and BiggerNumberMBS classes that use this class.
For the LargeNumberMBS class, we have also added the GetStringValue and SetStringValue methods. With GetStringValue you can query the specified value again and set the base and delimiter that you would like to have when outputting the number.
Dim l As New LargeNumberMBS(1234567890) Dim s0 As String = l.StringValue Dim s1 As String = l.GetStringValue // 1234567890 Dim s2 As String = l.GetStringValue(10, ",") // 1,234,567,890 Dim s4 As String = l.GetStringValue(8, "") // 499602d2 Dim s3 As String = l.GetStringValue(16, "") // 11145401322 Break // check in debugger
DynaPDF
Dyna PDF has received a new class, DynaPDFParserMBS. With these functionalities you can search for text on a PDF page and then output, delete or replace the text. With the method SetAltFont we can set an alternative font. With ParsePage we parse a page and store the page contents in an objects internally. Now we can call various methods, e.g. to find the text. With FindText we can search for a specific text on the page. In this method we then specify the desired search mode, e.g. you can decide whether you want to perform a CaseSensitive or CaseInsensitive search. There is also a parameter of type boolean, which is particularly useful if you have longer texts. This is because you can decide whether you always want to start at the beginning of the text or whether you want to continue searching from the last position.
If you have previously used the FindText method, you can now use the SelBBox property to determine where the text found is located on the page. In this property you have an object of the type DynaPDFRectMBS in which you can query the coordinates individually. For example, we can draw a rectangle around the hit to mark it. Instead of marking the text, we can also replace the found text with ReplaceSelText. Of course, you can also delete the text found. Either enter an empty string in ReplaceSelText to replace it, or delete the text using the DeleteText method, which deletes a text from an area described by a DynaPDFRectMBS object. To do this, we pass the object in the SelBBox property.
You can then use the WriteToPage method to write these changes back to the PDF page.
If you want to get the parsed text of the page, you can use the ExtractText method after you have called the ParsePage method, which returns the text.
If you are particularly interested in this topic, please have a look at our new example Find and Replace.
Original | After replace the text "Calling" with "Test" |
JSON
With the new release, you have the option of creating and using Patch and MergePatch for JSON. Patch and Merge Patch are formats used to describe changes to a JSON. You can use the PatchFromDiff and MergePatchFromDiff methods from the JSONMBS to detect these changes between two JSONs. Both have a different way of dealing with these changes as you can see here:
Dim JSON1 As New JSONMBS("{""people"":[{""first"":""Christian"",""last"":""Miller"",""city"":""Nickenich""}]}") Dim JSON2 As New JSONMBS("{""people"":[{""first"":""Peter"",""city"":""Nickenich"", ""zip"": 56645 }]}") Dim Patch As JSONMBS = JSONMBS.PatchFromDiff(JSON1, JSON2) Dim MergePatch As JSONMBS = JSONMBS.MergePatchFromDiff(JSON1, JSON2) Dim JSON1Text As String = JSON1.toString(True) Dim JSON2Text As String = JSON2.toString(True) Dim PatchText As String = Patch.toString(True) Dim MergeText As String = MergePatch.toString(True)
You can then apply the changes described by this patch to a JSON using the ApplyPatch and ApplyMergePatch methods.
Mails with CURL
We have added new properties to the CURLEmailMBS class with which you can now work. First, we now have properties that give us lists of the individual recipient groups and the data of the set sender. In addition, we can now query a list of headers. The encoding can now also be queried by property.
New functionalities for Mac
The MBS Xojo Plugins in version 24.0 offers some more new features for Mac users
NS Controls
We have also made a few changes to the NSContols. We have the new controls NSPathControlControlMBS and DesktopNSPathControlControlMBS. They are host a NSPathControlMBS view. The NSPathControl represents a file system path or virtual path.
The NSPathControlMBS class also receives two new events. The willDisplayOpenPanel event is called before the Open panel is shown but after its allowed file types are set to the cell's allowed types. At this time, you can further customize the Open panel as required. We also have the new event willPopUpMenu. This event is called before the pop-up menu is shown. At this time, you can further customize the menu as required, adding and removing items.
Similar to NSPathControlControlMBS, we also have new controls to host a NSSegmentedControl. These are then DesktopNSSegmentedControlControlMBS and NSSegmentedControlControlMBS.
We know that the double ControlControl can be confusing at the moment. Suggestions to rename are welcome, but unlikely to happen as it would break code
Mobile Ads
There is also news in the area of mobile ads. According to the Google EU user guidelines, you must reveal the stored user data to users in certain countries. Google offers developers the User Messaging Platform (UMP) SDK for this purpose. We have made the functionality available to you with the plugin. If you are interested in finding out more, take a look at our blog post Google Admob Update
But we have other small changes in this area. We have three new properties in the GADRequestConfigurationMBS class. The Property publisherPrivacyPersonalizationState lets you specify the personalization treatment that applies to subsequent ad requests. With tagForChildDirectedTreatment you indicates whether you would like your app to be treated as child-directed for purposes of the Children’s Online Privacy Protection Act. The Property tagForUnderAgeOfConsent indicates whether the user is under the age of consent.
New functionalities for Windows
Last but not least we offer some more new features for Windows users
Windows Bluetooth
We have two new events in the WindowsBluetoothLEDeviceMBS class. The PairAsyncCompleted event fires when PairAsync method finishes. The other new event is UnpairAsyncCompleted and is called when UnpairAsync method finishes.
WindowsPDFPage
In the middle of last year we already introduced the new topic Windows PDF with which we make the built-in PDF functionalities usable for Windows. In this release we want to extend the WindowsPDFPageMBS class with a few new methods. We can now render the PDF pages to different formats. The methods RenderToStream, RenderToMemory and RenderToPicture are available for this purpose.
We hope you will also find some interesting new features. We wish you a lot of fun with MBS Xojo Plugins version 24.0. If you have any Ideas for new cool features, need a license or have any questions, please contact us.