« Identify plugin versi… | Home | FileMaker Server 19.3… »

New in MBS FileMaker Plugin 11.3

In this article I want to introduce you the new functions from the MBS FileMaker Plugin in version 11.3.

Barcode

First of all, I would like to show you the new features in the Barcodes section. Until now you could only read barcodes in the plugin via the ZXing library. We have now changed this and make the reading of Barcodes with the ZBar library accessible. You can load the ZBar library, which you can also download from our website, with the new function Barcode.LoadLibrary. We specify in the parameters the file path to library. With Barcode.Loaded you can test, if ZBar is loaded. Using Barcode.ZBarVersion you can query the loaded version of the library. With Barcode.Scan you scan a barcode by using ZBar. The result will contain information about the Barcode as JSON text, for example the text of the Barcode. In the parameters of this function the image must be stored as container value or as GraphicsMagick reference. For example, if you want to scan an image from a file, you must first read the image into a variable with Container.ReadImageFile. Here you can see an example with the new barcode functions. The QR code that should be scanned and the ZBar library file are both located on the desktop:

Set Variable [ $Desk ; Value: MBS( "Folders.UserDesktop" ) ]

#Load ZBar Library
Set Variable [ $PathLibrary ; Value: MBS( "Path.AddPathComponent"; $Desk; "libzbar.0.dylib" ) ]
Set Variable [ $r ; Value: MBS( "Barcode.LoadLibrary"; $PathLibrary ) ]

#Is the ZBar library loaded?
Set Variable [ $Loaded ; Value: MBS( "Barcode.Loaded" ) ]
#Version of ZBar
Set Variable [ $Version ; Value: MBS( "Barcode.ZBarVersion" ) ]

# Scan
Set Variable [ $PathBarcode ; Value: MBS( "Path.AddPathComponent"; $Desk; "QRCode.png" ) ]
Set Variable [ $BarcodeImage ; Value: MBS( "Container.ReadImageFile"; $PathBarcode ) ]
Set Variable [ $BarcodeResult ; Value: MBS( "Barcode.Scan"; $BarcodeImage ) ]

#Dialog
Show Custom Dialog [ "QR Code with ZBar" ; "Loaded: " & $Loaded & "¶Version: " & $Version & "¶Barcode Content: " & $BarcodeResult ]

The dialog look like this:

Based on this example picture above.

If you are interested in more details please have a look at our new example Barcode Detection.fmp12 file.

DynaPDF

There are also innovations in the DynaPDF area. With the new function DynaPDF.DeleteNamedDest you can delete previously defined named destinations. In the parameters of this function you can address the named destination by name or by index. If you specify an empty string or an index < 0, all namespaces will be removed from the document.

With the latest version you can also rename Optional Content Groups (OCG). The DynaPDF.ChangeOCGName function is available for this purpose. In the parameters, first enter the OCG handle number and then the new name for the OCG.

CURL

For CURL we added support for pre-signed URLs. You can use our examples for Amazon S3 to upload files and then generate time limited URLs to access those files with CURL.AWSPresignURL to load them e.g. in a WebViewer. In the parameters of this function we specify the access key for AWS, the secret access key, the used region, the used service, the path for the URL and the domain. Additionally, if needed, we set the HTTP operation we want to perform, the time after which the request will be aborted, a list of parameters that are needed for the desired query, and an extra HTTP header.

An example call can look like this:

Set Variable [ $r ; Value: MBS( "CURL.AWSPresignURL"; "AKIAIOSFODNN7EXAMPLE"; "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"; "us-east-1"; "s3"; "/test.txt"; "examplebucket.s3.amazonaws.com"; "GET"; 86400 ) ]

This input will give us this URL:

This function also works for other compatible S3 services beside Amazon's like the one from Wasabi or Dell ECS.

We also have two more new functions from the CURL area. With the CURL.SetOptionCAInfoBlob function we sets CAInfo as a blob value. We pass information about a memory block with binary data of PEM encoded content holding one or more certificates to verify the HTTPS server. The CURL.SetOptionProxyCAInfoBlob sets the CAInfo for the HTTPS proxy.

JavaScript

A really cool new feature comes from the JavaScript area. To extend your functionality of FileMaker itself or to use already existing JavaScript code functions you already have for a while the component JavaScript available. That allows you to use JavaScript code without a web viewer locally in a FileMaker solution. Now there is a new feature, because you can use these functions not only locally, but you can use the functions also globally. That means you have to initialize the JavaScript functions once and then you can use it in all your FileMaker solutions. For example, you can build a function library in FileMaker that you can initialize to the beginning of your work and then use it in all your projects. In this example I will show you how to load a JavaScript function into memory that calculates the cubic root.

First we have to create a JavaScript environment with a name in the RAM. This normally remains until FileMaker is closed or you free the JavaScript environment, e.g. with JS.ReleaseAll.

Set Variable [ $r ; Value: MBS( "JS.New" ; "JS") ]

You add a function with JS.AddFunction to this environment as usual.

Set Variable [ $r ; Value: MBS( "JS.AddFunction"; "JS"; "CubicRoot" ; "function (x) { return Math.cbrt(x); }" ) ]

This function you can use now in any FileMaker file. You call this function from the global environment with the "JS.CF" function. An example call looks like this.

Set Variable [ $r ; Value: MBS( "JS.CF"; "CubicRoot"; 27 ) ]

If you have more than one JavaScript environment in memory, we recommend that you use the JS.CallFunctionValues function to call the functions, because you specify there which JavaScript environment to use.

With JS.List you can List all JavaScript environments.

If you want to see an example of a function library with JavaScript, feel free to take a look at our JavaScript Custom Functions.fmp12 example.

OCR

Also in the OCR area there is a lot going on in this version. With the OCR.Load function we can load the new tesseract 4.1 version. In the parameters we specify the path to the library. If the leptonica library and the tesseract library do not have the same library file, we have to load the leptonica library first with this function and then the tesseract library. With the function OCR.IsLoaded you can check if a newer tesseract (newer then 3.0.2) is loaded. With OCR.Version we get the version of the loaded tesseract library. We also have two new functions for loading images. OCR.SetImageContainer loads the images from a container. OCR.SetImageFile, on the other hand, loads the image directly from a file.

Archive

The New Archive.GZipDecompress function extracts content of a gzip file and return the content as a container value. Since a pure gz file doesn't have an archive inside like a tar.gz, this function will return the uncompressed content as new file.

List and Quicklist

Now let's move on to the List and Quicklist sections. Here we have two very similar new functions for List and Quicklist: List.GetColumn and QuickList.GetColumn. We have a list in which there are multiple entries in multiple rows. The entries within these lines can be separated with Tap (Char (9)) for tab separated text and semicolon or comma for CSV separated text. With these functions we can now output a single column as a list. For example, we enter a 1 in the parameters and get the entries of the second column (because the counting begin with 0). I would like to show this with an example.

We have the list „Hello,123,abc¶World,456,def“ and want the first column as List. As parameter we first insert the list, then the Separator in this case comma and then the column index. For the first row it is zero. The script step look like this:

Set Variable [ $r ; Value: MBS( "List.GetColumn"; "Hello,123,abc¶World,456,def"; ","; 0) ]

We also have the function List.MapEntries. In this function we first specify a list of keys, then a list of the keys from which we want to have the values (the second key list is a subset of the first key list) and finally a list with values that should be assigned to the keys of the first key list. As a result we get the values that belong to the entries of the second key list. Let's imagine we have a list with four values, which describes the following assignment: 1: "Hello" 2: „World" 3: „Test" 4: „Other" So if we want to have the value to key 2 and 4 we write the script step as follows:

Set Variable [ $Values ; Value: MBS( "List.MapEntries"; "1¶2¶3¶4"; "2¶4"; "Hello¶World¶Test¶Other" ) ]

The result is World¶Other.

Text

Since version 9.3 we have the function Text.Styles in the plugin, in which we can define a text style for a text. As a result we get a JSON that contains the information about the styled text. With the new function Text.FromStyles we can now also convert such JSON texts into a styled text, which we can then e.g. output in a field in FileMaker. In such a JSON we find different information. For example, whether the text has a color or a font and if that is true, then we also have the font or color in the JSON specified.

Another new function, the Text.RTFToText function turns RTF text into styled text in FileMaker.

FileMaker

With the new function FM.CF it is now also possible to call custom functions, that we first create in a dictionary, globally. The custom function is called with FM.CF. In the parameters we specify the dictionary in which the function is entered, the name of the function and finally all parameters that the function requires for the call. The special thing about this technique is that we add the custom functions to a named directory. It is independent of the FileMaker file in which it was defined. These custom functions can also be used across FileMaker files. If you are interested in this topic, please have a look at our FileMaker Custom Functions.fmp12 example.

System Sound

Also a really cool new function is the App.PlaySystemSound function which plays a system sound specified in the parameters. For example, you can play a system sound when you open a dialog box or play a system sound when the content of a field have changed. The names of the system sounds can be found under macOS in the Path: /System/Library/Sounds folder and on Windows look into registry at HKEY_CURRENT_USER\AppEvents\EventLabels section.

Mac

There are also new features for Mac:

System Info

In the SystemInfo section there are two new functions that display information for macOS 12. The SystemInfo.IsLowPowerModeEnabled function returns 1 if a Mac with macOS 12 or an iPhone with iOS 9 have a low batterie status.

Furthermore we have the new system function SystemInfo.isMonterey. With this function we ask if the user operating system is the new MacOS 12, Monterey. For both functions: For older macOS, Windows and Linux systems we automatically get a 0 as return.

Web Viewer

With the new version, you can now use the new functions WebView.SetUsePrivateBrowsing and WebView.GetUsePrivateBrowsing to set and query the private browsing desire. You call this before a WebViewer is created and make your wish. When FileMaker creates a WebViewer, we intercept and if you like to have private browsing, it switches to a non persistent data storage. A Script can have the following structure:

Call MBS("WebView.SetUsePrivateBrowsing"; 1)
Go to a layout with web viewer
Load an URL
Script pause for maybe 0.1 seconds to let FileMaker create web viewer.

You can call WebView.SetUsePrivateBrowsing again pass 0.

If you like have all Web Viewers in FileMaker be private, just call WebView.SetUsePrivateBrowsing once on startup in your start script. The setting persists till you disable it or FileMaker quit. In the case of having two web viewer with both private browsing, you can login into the same website with two different accounts. Normally those would share the cookies and two accounts won't work.

Print Dialog and Page Setup Dialog

The new functions for the page setup dialog for printing and the printer dialog are all about the page height and width. With the new functions you can query and set the page height and width.

Quick Lock

In the QuickLock topic we have the two new functions for iOS, QLPreviewPanel.SetSharingAllowed and QLPreviewPanel.GetSharingAllowed to allow sharing in preview and to query the status of this setting.

We hope you will also find some interesting new features. We wish you a lot of fun with MBS FileMaker Plugin Version 11.3. If you need a license or have any questions, please contact us.
by Stefanie Juchmes

FileMaker Plugin
27 07 21 - 10:13

Start Chat