Edit and Update for SQLDatabaseMBS class

For years we had requests to add support for Edit and Update functions in the RecordSet to our own classes, SQLDatabaseMBS and SQLConnectionMBS. Well, till now we didn't have an idea how to do this well for all database types.

Recently we got some ideas, so we started to implement them. Let me explain how it works now: First we got a little SQL parser to find the table name in a SQL statement. If the SQL is complex, has some JOIN operator or references multiple tables, we stop and return an empty string. That means we won't allow you to edit the record set from such a statement.

The function is available for you to try as FindTableName in SQLGlobalsMBS. Let us know if you can find some SQL, where it doesn't work as expected. As we use it later with a record set, the SQL has already be parsed and accepted by the database server, so it is always valid SQL.

If you call Edit on the RecordSet, we just check the pre-conditions. We currently don't do any record locking there, but could maybe in future.

Next you may assign values to some fields in the RecordSet. Please only assign data fields and never the primary key fields as that helps us distinguish the fields.

Finally you call the Update method. The plugin looks up the table name. We separate the fields into two categories: Fields you changed are data fields. Also we count all numeric, double, interval, BLob, CLob and date/time fields in this category. What is left will be a few string and integer fields, which are the invariants to identify the record. This usually may include ID fields and UUID fields. You may notice that we don't need to query the schema this way, which is great when you have 15 different target databases.

To be sure we only edit one record, we make a SELECT query to count the records matching the given keys. This should always find exactly one record. But if your primary key is not part of the record set and no other unique key was selected, we find multiple records and return an error. We fill in the key values from the old values in the RecordSet and fill the new values as passed by Xojo. Data type is either given by Xojo as parameter to the plugin or we pick it from the matching field.

If something goes wrong now, we return an error. For examples if you used AS in the SQL to rename a field or an expression, the update statement will fail with unrecognized field name. The call may also fail if we can't identify a key field.

If you like to get a more detailed update statement or control how it is build, you may just use prepared statement with the UPDATE statement you like to use. Otherwise you can collect record data via dictionary and use our InsertRecord/UpdateRecord methods with those dictionaries:

UpdateRecord(TableName as String, Record as Dictionary, Keys as Dictionary)
InsertRecord(TableName as String, Record as Dictionary)

Please try soon with next pre-release. This new feature may need some testing and tuning. For example we may need to tune the auto generated SQL for some database types. But since this is working, converting a Xojo example from SQLiteDatabase to SQLDatabaseMBS is only a handful of lines to change.

Converting Xojo project to use MBS SQL Plugin

If you like to convert an example project from Xojo to use our plugin, you only need a few simple changes. For example in the SQLiteExample project, you need to only do a few steps:

  • First, search for SQLiteDatabase and change the db property in app to use SQLDatabaseMBS as class name.
  • Next change the new line to use SQLDatabaseMBS class for Action event in CreateDBButton class.
  • Add line to enable SQLite internal database a bit higher there:
    call InternalSQLiteLibraryMBS.Use
  • Change from DatabaseFile to using path in DatabaseName:
    App.DB.DatabaseName = "SQLite:"+dbFile.NativePath
    The prefix SQLite: tells MBS Xojo SQL Plugin to use the right database client library, e.g. the internal one we activated before.
  • Remove the call for CreateDatabase as database is created automatically with our plugin if needed. Instead call connect to connect to new empty database file:
    app.db.Connect

Now you can run the project:

That was it. MBS Xojo SQL Plugin implements the database interface from Xojo and works with both older RecordSet and newer RowSet classes. A few examples are tricky to port as they used Edit/Update on the RecordSets, but we may have a solution for that soon.

Please don't hesitate to contact us if you have questions.


MBS Xojo Plugins Version 21.0 News

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

Memory Block

Let's start with the new methods from the class MemoryBlock. With the SetBitMBS method we can set a single bit. To do this, we first specify the bit that should be set by its number. Then we have several other options to choose from. If we make now no further specifications to the value then the value of the bit is set automatically to 1. If we pass a 1 or a 0 in the parameters, the bit is set accordingly. If we pass a true or false then the bit is set to 1, according to the logical values, for true and to 0 for false. With the method IsBitSetMBS you can check whether the bit is set. With the method GetBitMBS you get the value of a bit. If you want to reset the bit to zero you can use the method ClearBitMBS.

Dim m As New MemoryBlock(100)

m.SetBitMBS(123)
Dim v1 As Boolean = m.IsBitSetMBS(123)
m.ClearBitMBS(123)

DynaPDF

We have also a new method for the component DynaPDF. With the method GetTypoLeading from the DynaPDFMBS class we get the typographic leading or line height of the active font. The method can be called after a font was activated in the graphics state, e.g. with SetFont(), SetFontEx(), SetCIDFont(), or ChangeFont(). This helps you to layout your PDF document.

For WriteFText, WriteFTextEx and ConvertStyledText can now use a given leading relative to the font size as shown in the example output on the right.

Additionally we have two new Properties. In the properties you find the information about the number of warnings (WarningCount) and the number of errors (ErrorCount) that occurs while the creating of the PDF.

DynaPDF got new functions to convert a PDF page to outlines with the Optimize function. This makes copying the text impossible as all font information is converted to vector graphics. Outlines are vector graphics describing how a font looks and are highlighted in different colors here:

(more)

Text Encoding Speedups

A client contacted us about some performance problems with our MBS Xojo XL Plugin. Writing 5000 rows into Excel documents takes some time. Looking into a test project, we found that conversion from UTF-8 to UTF-16 or UTF-32 takes most of the time in the whole process. Text encoding conversion needed about 70% of the processing time.

Luckily we found a way to speed up the text encoding conversion and the results are phenomenal. For the client, we got time down from 195 seconds to 80 seconds. The improvements are solely due to optimized text encoding handling.

We did some measurements here with our own test projects:

512000 calls for WriteString method in XLSheetMBS take about 15.9 seconds with old plugin (21.0), but only 4 seconds for newer plugin (21.1). The effect shows well here as text is just added to internal data structures.

The same 512000 calls send to WriteText method in DynaPDFMBS reduce from about 28.6 down to 24.9 seconds. Here the encoding for text to PDF encoding takes more time than our encoding conversion.

This changes will come with 21.1pr1 to be tested by you all. Please do not hesitate to contact us with your questions.
And if you have ideas for other areas where we could improve performance, please let us know.

MonkeyBread Software Releases the MBS Xojo Plugins in version 21.0

Nickenich, Germany - (January 19th, 2021) -- MonkeyBread Software today is pleased to announce MBS Xojo Plugins 21.0 for macOS, Linux and Windows, the latest update to their product that is easily the most powerful plugin collection currently available for Xojo. MBS Xojo Plugins have been updated and now includes over 2800 classes and 72,000 documented features, and the versatile plugins have gained more new functions:

In this release we include plugins for iOS and Apple Silicon. All plugins have been compiled for the new CPU type from Apple. Over 300 plugin parts are ported for iOS and work well. We created a few new example projects for iOS, but usually you can copy & paste code from desktop to iOS projects. We start with new iOS controls for SceneKit (SCNIOSControlMBS), MapKit (MapKitIOSControlMBS) and WebKit (WKWebViewIOSControlMBS). Those iOS controls are nearly identical to the Mac desktop controls, except they now work on iOS.

For macOS the new NSCollectionViewControlMBS control provides access to Apple's implementation of a collection view. This is the control used in applications like Photos or Finder to show a grid of files or photos. You can use container controls in Xojo to provide the views. The control comes with 10 more classes like NSCollectionViewMBS class.

On Windows you can report errors with WindowsReportErrorMBS class to the Windows error log. For WebView2 you can run JavaScript synchronously with ExecuteScriptSync in our WebView2ControlMBS control. The WindowsExecuteMBS function can now minimize the new application you call with ShowWindow parameter. We updated IEDocumentMBS and IEWindowMBS classes to allow you to query frames content. For DirectShow we added more methods to our DirectShowPinMBS class.

On macOS you can run can now manage the contextual menu with new events in WKWebViewControlMBS control. For AVFoundation's AVAudioEngineMBS class we added functions for manual rendering, so you can convert audio files without playing them in real time, but faster.

DynaPDF got updated to newer version and this includes the new GetTypoLeading method. The DynaPDFMBS class now counts errors and warnings, so you can check on the end whether an error happened in-between. We let you pass leading parameter (line spacing) for converting styled text from TextArea or StyledText class to DynaPDF syntax.

The MemoryBlock class got new bit set functions. The MarkDown functions now handle foot notes. The FileMappingMBS class can now handle shared memory views with over 2 GB in size for 64-bit systems. The HTMLToPlainText function in MimeEmailMBS class is improved to better convert HTML to text.

Finally we updated SQLite library to version 3.34.0, curl to 7.74.0, DynaPDF to 4.0.46.132, SQLAPI to 5.1.3 and Xcode to version 12.3.

See release notes for a complete list of changes.

MBS Xojo Plugins, version 21.0pr8

New in this prerelease of the 21.0 plugins:
  • Added ShowWindow flag for WindowsExecuteMBS method.
  • Added AcceptTabs property to WKWebViewControlMBS control.
  • Fixed ChartDirector to not need Visual Studio 2019 runtime libraries.
  • Fixed problem with WordFile functions and some Word documents with older encodings.
  • Added more methods to DirectShowPinMBS class.
Download: monkeybreadsoftware.com/xojo/download/plugin/Prerelease/.
Or ask us to be added to our shared Dropbox folder.

Visual Studio 2019 dependency

We moved earlier in August 2020 to the newer Visual Studio version 2019 to build our plugins. All our Windows plugins are now build with that version.

But there was/is one problem: Some of the plugins got a new dependency to VCRuntime140_1.dll, which is part of the Visual Studio 2019 runtime libraries. That is annoying since it requires all our users to install those libraries. It would be much easier to not have that dependency and be only relaying on the Visual Studio 2015 libraries. Those are required for FileMaker Pro/Server as well as Xojo and so preinstalled with installing those. And Windows 10 comes with those libraries pre-installed as well.

For MBS Xojo Plugins 21.0 we removed the dependency and we are looking forward to keep all newer versions for at least this year free of the VCRuntime140_1.dll dependency.

For 21.0pr7 we fixed this for WebView2, WindowsHTMLViewer, WindowsStore parts in MBS Xojo Win Plugin and MBS Xojo XMP Plugin. The last plugin to get fixed is MBS Xojo ChartDirector Plugin, where we are able to remove the dependency for next pre-release 8 and the final release next week.

Let us know if you have some questions about this. Please try pr8 later this week.

MBS Xojo Plugins, version 21.0pr7

New in this prerelease of the 21.0 plugins:
  • Added Frames function for IEDocumentMBS and IEWindowMBS classes.
  • Added Document property to IEWindowMBS class.
  • Added GetTypoLeading method for DynaPDFMBS class.
  • Fixed CMap loading problem with DynaPDFMBS class on macOS and Linux.
  • Fixed WebView2, WindowsHTMLViewer, WindowsStore and XMP plugins to not need VS 2019 runtime libraries.
  • Added messageDrainControl and OwnerControl properties to DirectShowVideoWindowMBS class.
Download: monkeybreadsoftware.com/xojo/download/plugin/Prerelease/.
Or ask us to be added to our shared Dropbox folder.

Academic licenses for MBS Plugin

Not sure if you know, but for about 20 years already we offer academic discounts for students learning to program. Both our FileMaker and Xojo plugins are available with academic discounts including DynaPDF licenses.

Recently we cleaned up our order pages, so academic prices are no longer listed. This basically cuts the list of store items by half for us. It's much easier to provide you with a coupon code to order and use the same website as everyone else.

If you are interested in an academic license, please contact us via email and provide a proof of status. That may be a copy of a university or school identity card. For young people below age of 25, we may just accept a proof of birth date.

Over the years we got quite a few students, some of which grown up to now use full commercial licenses for their work. From time to time we also granted academic status to retired, unemployed or other people, who asked for this with a compelling reason.

Please note that an order for an academic license from a company doesn't usually work. We expect companies to buy commercial licenses. Same if you receive any compensation for your work.

For Non-Profit organization supporting humanity, we also provide a discount on request.

Please don't hesitate to contact us if you have questions.

DynaPDF Optimize command

As you may know we have a great Optimize command for DynaPDF. You can use it on PDF documents in both FileMaker and Xojo plugins. Over time the command got more and more powerful and we like to write here about some of the features.

In general the function rebuilds the content stream of all pages, templates, patterns, annotations, and form fields. This may remove errors in the content stream and produce a consistent document.

When you specify the flags, the default flag value (0) just rebuilds the content stream and fixes errors. You may specify "InMemory" to have changes made in a way, that the PDF is in memory and not flushed to the current output. Normally you may not notice the difference, but if you like to continue writing to the PDF, the memory flag is needed.

Scale images

The Optimize function can reduce the file size of PDF files. You can pass the ScaleImages flag and then all images are checked. You can define a minimum and target resolution for images. All pictures with at least the minimum resolution are checked. This avoids that we look on icons for example and only process pictures with a significant resolution. DynaPDF scales the images down to the target resolution and compresses them with the compression algorithm you specify, usually JPEG. If the final picture is smaller in size, we store it, otherwise we keep the original image. The reason is that often one bit tiff images can be smaller than a reduced resolution JPEG file.

You can pass flag SkipMaskedImages to skip masked images as JPEG compression may not work well with pictures, where a specific color is used to mark transparency. The check whether new picture is smaller than original image can be disabled via NoImageSizeCheck flag.

If you like to get images compressed with JBIG2, you can use CompressWithJBIG2 flag. This can drastically reduce the file size since JBIG2 compression achieves much higher compression rates than any other 1 bit image filter that PDF supports. The JBIG2 compression filter in DynaPDF is lossless, that means the original image quality will be preserved. Great to combine with ConvertGrayTo1Bit flag discussed below.

(more)

Adding leading factor for converting styled text

When you output styled text via MBS Plugins and DynaPDF, we convert the styled text for you in commands for DynaPDF. For this conversion we recently added a leading factor to define the line spacing based on the font size. You can still define leading (distance between two base lines) in points if you like, but the relative measure to font size is probably better for a lot of cases. Of course only makes an effect if font size changes within a text.

For FileMaker we added LeadingFactor parameter to DynaPDF.ConvertStyledText, DynaPDF.WriteStyledText and DynaPDF.WriteStyledTextEx functions.

For Xojo we added LeadingFactor parameter for WriteStyledText, WriteStyledTextEx and ConvertStyledText methods in DynaPDFMBS class. The default value for the new parameter is -1, which allows us to detect whether you use the parameter.

For all the functions, please pass nothing (omit parameter) or zero for automatic behavior like it used to be: Leading being the font size. You can pass a factor like 1.2 or 1.5 to increase line spacing as needed.

Available in current pre-release. Please don't hesitate to contact us with your questions.

MBS Xojo Plugins, version 21.0pr6

New in this prerelease of the 21.0 plugins:
  • Updated DynaPDF to version 4.0.46.132.
  • Added manual rendering functions to AVAudioEngineMBS class.
  • Fixed a memory leak in WordFileMBS class.
  • Added LeadingFactor parameter for ConvertStyledText, WriteStyledText and WriteStyledTextEx in DynaPDFMBS class.
  • Changed DynaPDFMBS to not raise exception if WriteFText function is cancelled.
  • Revert workaround for universal plugins in Xojo 2020r2. Please use Xojo 2020r2.1 now for building universal apps.
  • Changed plugin class registration to skip desktop controls for iOS and iOS controls for Windows/Linux where you can't build for iOS.
  • Disabled AVCaptureDeviceInputSourceMBS class for iOS.
  • Fixed an issue with SQL plugin connect to MySQL when server doesn't know utf8mb4 text encoding.
  • Added isiOSAppOnMac property for NSProcessInfoMBS class.
Download: monkeybreadsoftware.com/xojo/download/plugin/Prerelease/.
Or ask us to be added to our shared Dropbox folder.

Becoming Xojo MVP

Today Xojo Inc. asked whether I want to join their MVP Program.

Well, as a close contributor to the Xojo community for over 20 years, there was no hesitation to join the opportunity this gives.

Beside the honor of being recognized as a valuable member in the community, this may bring a few communications privileges. Like a place to chat with Xojo people directly, but now under NDA, so it may be about different topics. Not sure yet whether this comes with any feedback or forum privileges.

As a new member of the informal advisory committee, I am keen to see what Xojo Inc. will present to MVPs ahead of development and launch. Especially getting an insight into future projects in planing and alpha state may be good to advise the company about what they are about to implement. One thing to monitor over years is whether such an advisory board (or call it a partner council) actually has an effect on the course of action. Not just being informed early and say our opinion, but actually to have the company change their plans for the better after a discussion.

We'll see how well it works out. I may invite all the other MVPs to a dinner in London around the next Xojo conference for a discussion about the program.

Thanks for Gavin for his time on the board. And thanks for the MVP and staff members, who voted for me to be invited.

xDev 19.1 Issue

The January/February (19.1) issue of xDev Magazine is now available. Here's a quick preview of what's inside:

Moving to Apple Silicon by Marc Zeedar
Apple has just revolutionized the PC desktop with a major leap ahead in performance, power efficiency, and value by introducing their own CPU architecture. But just what does Apple Silicon mean to the Xojo developer?

Working with Workers by Marc Zeedar
Writing multi-core apps in Xojo has traditionally been difficult. Now Xojo introduces Workers, a system that lets Xojo do the heavy lifting so you can take advantage of a multi-core CPU. Learn how to use them to speed up your app's processing power.

Get Ready for Git (Part 2) by Justin Elliott
In part 1, Justin showed how to install, setup, and use Git. This time he demonstrates how to use Git with your Xojo projects, track changes, manage branches, fix sync conflicts, and more.

MapKit (Part 8) by Markus Winter
Markus shows how to further customize annotation views in Apple's MapKit in Xojo.

PLUS: MacBook Air M1 review, creating gradients with Xojo, Xojo 2020 Release 2, Best of the Web, and more!

Two years junior developer at MBS

Two years ago I had my first working day at MBS.

Today I have the opportunity to résumé about these two years. I have learned a lot in this time, especially I got to know the programming language Xojo and the FileMaker platform and was allowed to realize some exciting projects. I also wrote some articles for the German FileMaker Magazine (see here) and the Xojo Developer Magazine. I also gave presentations at conferences on- and offline.

2020 was a very special year in which we all outgrew ourselves and had to find new solutions for problems that were unprecedented until then. Digitalization got the 7 mile boots on and home office was the new work routine for many. I was able to learn a lot in the last two years. Not only technical knowledge, but I also got to know many kind and interesting people and was allowed to work with them. I would like to thank all of you who have welcomed me so kindly into the community. I am looking forward to many new and interesting exchanges in the next few years, hopefully some of them will take place offline again.

I wish you now a happy, successful and healthy year 2021!

Yours truly Stefanie Juchmes

MBS Xojo Plugins, version 20.6pr5

New in this prerelease of the 20.6 plugins: Download: monkeybreadsoftware.com/xojo/download/plugin/Prerelease/.
Or ask us to be added to our shared Dropbox folder.
The biggest plugin in space...

Archives

Jul 2024
Jun 2024
May 2024
Apr 2024
Mar 2024
Feb 2024
Jan 2024
Dec 2023
Nov 2023
Oct 2023
Sep 2023
Aug 2023
Jul 2023
Jun 2023
May 2023
Apr 2023
Mar 2023
Feb 2023
Jan 2023
Dec 2022
Nov 2022
Oct 2022
Sep 2022
Aug 2022
Jul 2022
Jun 2022
May 2022
Apr 2022
Mar 2022
Feb 2022
Jan 2022
Dec 2021
Nov 2021
Oct 2021
Sep 2021
Aug 2021
Jul 2021
Jun 2021
May 2021
Apr 2021
Mar 2021
Feb 2021
Jan 2021
Dec 2020
Nov 2020
Oct 2020
Sep 2020
Aug 2020
Jul 2020
Jun 2020
May 2020
Apr 2020
Mar 2020
Feb 2020
Jan 2020
Dec 2019
Nov 2019
Oct 2019
Sep 2019
Aug 2019
Jul 2019
Jun 2019
May 2019
Apr 2019
Mar 2019
Feb 2019
Jan 2019
Dec 2018
Nov 2018
Oct 2018
Sep 2018
Aug 2018
Jul 2018
Jun 2018
May 2018
Apr 2018
Mar 2018
Feb 2018
Jan 2018
Dec 2017
Nov 2017
Oct 2017
Sep 2017
Aug 2017
Jul 2017
Jun 2017
May 2017
Apr 2017
Mar 2017
Feb 2017
Jan 2017
Dec 2016
Nov 2016
Oct 2016
Sep 2016
Aug 2016
Jul 2016
Jun 2016
May 2016
Apr 2016
Mar 2016
Feb 2016
Jan 2016
Dec 2015
Nov 2015
Oct 2015
Sep 2015
Aug 2015
Jul 2015
Jun 2015
May 2015
Apr 2015
Mar 2015
Feb 2015
Jan 2015
Dec 2014
Nov 2014
Oct 2014
Sep 2014
Aug 2014
Jul 2014
Jun 2014
May 2014
Apr 2014
Mar 2014
Feb 2014
Jan 2014
Dec 2013
Nov 2013
Oct 2013
Sep 2013
Aug 2013
Jul 2013
Jun 2013
May 2013
Apr 2013
Mar 2013
Feb 2013
Jan 2013
Dec 2012
Nov 2012
Oct 2012
Sep 2012
Aug 2012
Jul 2012
Jun 2012
May 2012
Apr 2012
Mar 2012
Feb 2012
Jan 2012
Dec 2011
Nov 2011
Oct 2011
Sep 2011
Aug 2011
Jul 2011
Jun 2011
May 2011
Apr 2011
Mar 2011
Feb 2011
Jan 2011
Dec 2010
Nov 2010
Oct 2010
Sep 2010
Aug 2010
Jul 2010
Jun 2010
May 2010
Apr 2010
Mar 2010
Feb 2010
Jan 2010
Dec 2009
Nov 2009
Oct 2009
Sep 2009
Aug 2009
Jul 2009
Apr 2009
Mar 2009
Feb 2009
Dec 2008
Nov 2008
Oct 2008
Aug 2008
May 2008
Apr 2008
Mar 2008
Feb 2008