We got a few tips and tricks collected for you in the last week.
1. App.Constructor
If you need code to run really first, you may go with the constructor of the Application object. This constructor runs before the Opening event, so it is your chance to do very early initialization before all other events run. But using Constructor can be tricky since you need to call the constructor on the super class and match the signature, which is not always easy to know. Let us show you how the constructors would like
Console and Desktop targets:
Sub Constructor()
System.DebugLog CurrentMethodName
End Sub
Web target:
Sub Constructor()
System.DebugLog CurrentMethodName
// Calling the overridden superclass constructor.
Super.Constructor
End Sub
iOS target:
Sub Constructor(launchOptions As ptr)
System.DebugLog CurrentMethodName
// Calling the overridden superclass constructor.
Super.Constructor launchOptions
End Sub
For some projects we use constructor to put in some logging or plugin based exception catching very early to catch issues before App.Open event runs. See
NSExceptionHandlerMBS and
GlobalExceptionHandlerMBS classes.
(more)
New in this prerelease of the 23.5 plugins:
Download:
monkeybreadsoftware.de/xojo/download/plugin/Prerelease/
Or ask us to be added to our shared DropBox folder.
Just six months left until we start our MBS Xojo Developer Conference in Andernach, Germany. We know it is still early, but we already got a few speaker proposals and already the first dozen registrations from six different countries: 🇩🇪, 🇳🇱, 🇬🇧, 🇺🇸, 🇫🇷 and 🇨🇭.
Please join us 25th and 26th April 2024 in Andernach, Germany for a great Xojo developer conference. You may consider to arrive 24th April to join the evening reception in the hotel. Or even arrive earlier to join our Xojo training day. And if you come from far away, how about staying longer and do a bit of sight seeing with the group on Tuesday?
If you used our older
JSONMBS class and now move to 23.5 version of
MBS Xojo Plugins, you may notice a few changes. The new class is better in many ways, like interface compatible to JSONItem class, adds new Query, Search and Replace methods as well as handling errors better.
We got new kType* constants for new node types. Error, True, False and Number types are gone and we got new things like Boolean, ByteString, Int64, Single, Double and UInt64. The byte string is for handling MemoryBlocks in JSON, which can encoded as Hex, Base64 or Base64URL as needed.
We now raise exceptions for all bad operations. So checking handle for 0 and checking ParseError property is gone. You can inspect the exception for it's message property to see an error message.
We preserve numbers in exact representation. If you store 1.2345 as currency into JSON with our plugin, it will stay 1.2345 and not convert internally to a double and get output as 1.2344999999999999307. Our IsNumber function handles this correctly. So if a floating point number is stored internally as string, you may see kTypeString for it, but IsNumber returns true as it's a string we use to hold a number and output it as number. We also got functions like IsInt64, IsUInt64, IsInt32 and IsUInt32 which check for IsNumber and the range.
(more)
New in this prerelease of the 23.5 plugins:
- Fixed isiOSAppOnMac and isLowPowerModeEnabled properties in NSProcessInfoMBS class to work in iOS target.
- Updated DynaPDF to version 4.0.80.232.
- Changed Orientation property in DynaPDFPageMBS class to be settable.
- Added kctPDFA_4, kctPDFA_4e and kctPDFA_4f constants to DynaPDFMBS for CheckConformance to convert to PDF/A 4.
- Added kpvPDFA_4, kpvPDFA_4e and kpvPDFA_4f version constants for PDF/A 4.
- Added kcoDefault_PDFA_4 constant for default flags for PDF/A 4 conversion.
- Tuned JSONMBS class.
Download:
monkeybreadsoftware.de/xojo/download/plugin/Prerelease/
Or ask us to be added to our shared DropBox folder.
JMESPath (pronounced "jay-mess-path") is a query language and a specification for searching and extracting data from JSON documents. It provides a way to perform complex queries and transformations on JSON data, making it easier to work with structured data within JSON objects. JMESPath is similar in concept to other query languages like SQL for databases or XPath for XML documents, but it's specifically designed for JSON.
We add JMESPath to our MBS Xojo Util Plugin for the upcoming version 23.5 with the Search()) function in JSONMBS class. You may use this function to find things and then also check Replace() to replace values you selected with an expression.
(more)
New in this prerelease of the 23.5 plugins:
- Changed CSIdentityMBS class to have 15 properties visible in debugger.
- Changed localizedName property in CSIdentityAuthorityMBS class to be debugger visible.
- Fixed an issue with JSONMBS returning single instead of double value.
- Added ValueByteString property in JSONMBS class.
- Added ByteStringEncoding shared property to JSONMBS class.
- Added LineLengthLimit and NewLineCharacters shared properties to JSONMBS class.
- Added NewByteStringNode method to JSONMBS class.
- Added renameNode and adoptNode methods to XMLDocumentMBS class.
- Added MongoDB Watch Changes example project to show MongoChangeStreamMBS class.
- Added Constructor to StringHandleMBS class taking MemoryBlock.
Download:
monkeybreadsoftware.de/xojo/download/plugin/Prerelease/
Or ask us to be added to our shared DropBox folder.
Let's play a bit with our new JSONMBS class in Xojo and the query function there to run a few queries.
You may want to learn a bit about JSONPath and especially the implementation we use: JsonConsJsonPath.
Let me give you a bit of a summary about JSONPath here:
JSONPath is a query language used for extracting data from JSON documents. It is similar in concept to XPath, which is used for querying XML documents. JSONPath allows you to navigate and filter through the elements and values in a JSON structure to retrieve specific data or perform operations on it.
Here's an overview of the basic syntax and features of JSONPath:
(more)
New in this prerelease of the 23.5 plugins:
- Fixed picture output in ReSVGMBS class to not invert alpha for console projects.
- Updated DynaPDF to version 4.0.79.231.
- Added CreateGeospatialMeasure method to DynaPDFMBS class.
- Updated SQLAPI to version 5.2.6.
- Updated SQLite to version 3.42.1.
- Updated CURL to version 8.4.0.
Download:
monkeybreadsoftware.de/xojo/download/plugin/Prerelease/
Or ask us to be added to our shared DropBox folder.
Anyone using Oracle or Microsoft SQL Server out there with Xojo?
OracleDatabase and MSSQLServerDatabase class were deprecated in Xojo 2023r2 and you are recommended to use ODBCDatabase class instead.
If you need native access to Oracle, Microsoft SQL Server and other databases, your best choice is to use our
MBS Xojo SQL Plugin.
We provide direct access to CubeSQL, Centura SQLBase, DB2, DuckDB, Firebird, Informix, InterBase, MariaDB, Microsoft Access, Microsoft SQL Server, MySQL, ODBC, Oracle Database Server, PostgreSQL, SQL Anywhere, SQLite, SQLCipher and Sybase. And of course we got
MongoDB classes, too.
Please try it and let us know if you have questions.
Your desktop app made in Xojo can take advantage of new menu features in macOS Sonoma. You can use section headers as well as color palettes. And you may use our SystemInformationMBS.isSonoma function a lot to check if your application runs on macOS Sonoma. Then you can dynamically use the new features, if you have macOS 14.0 or higher.
Let's start with the Opening event of the application or a window, where we edit the menu bar. We Query menu item (NSMenuItemMBS) representing the EditMenu and start by adding a separator item there. Then we create a section header. To avoid the objects being destroyed too early, we store the references in properties.
For the color palette, we first collect a few NSColorMBS objects in an array as well as the matching titles. Then we create a palette menu for them. To later catch the event for a selection, we connect the PaletteSelectionChange event and add the new menu as a submenu to a new menu item.
(more)
New in this prerelease of the 23.5 plugins:
- Added new methods and properties to NSMenuMBS and NSMenuItemMBS for macOS Sonoma for palette menus and section headers.
- Optimized Key function in JSONMBS class.
- Fixed plugin not loading on macOS 10.13.
- Fixed IsInt64 property in JSONMBS class to not mark number like strings as number.
- Added Compact and CaseSensitive properties for JSONMBS class.
- Fixed a problem with PackBitsMBS not working properly for Linux ARM 64-bit.
- Fixed edge case for EncodingToHTMLMBS function on Linux.
Download:
monkeybreadsoftware.de/xojo/download/plugin/Prerelease/
Or ask us to be added to our shared DropBox folder.