« MBS @ FMTraining.TV -… | Home | Meet Christian at Cla… »

New in MBS FileMaker Plugin 14.0

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

DynaPDF

Let's start with DynaPDF. DynaPDF has received new parser functions. With these functions you can search for text on a PDF page and then delete or replace it. For example, if you already have an imported page, you can create a parser object with DynaPDF.Parser.Create. With the function DynaPDF.Parser.SetAltFont we can then set an alternative font. With DynaPDF.Parser.ParsePage we parse a page and store the page contents in an objects internally.

Now we can call various functions, e.g. to find the text. With DynaPDF.Parser.FindText we can search for a specific text on the page. In this function 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 that 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 DynaPDF.Parser.FindText function, you can now use DynaPDF.Parser.SelectionBBox to determine where the found text is located on the page. We thus receive a list of coordinates that describe a box around the location where the text was found.

For example, we can draw a rectangle around the match to mark it. Instead of marking the text, we can also replace the found text with DynaPDF.Parser.ReplaceSelText. Of course you can also delete the found text. To do this, either enter an empty string in DynaPDF.Parser.ReplaceSelText or delete the text using the DynaPDF.Parser.DeleteText function, which deletes text from an area defined by coordinates. To do this, we pass the coordinates that we receive with the DynaPDF.Parser.SelectionBBox function.

You can then use the DynaPDF.Parser.WriteToPage function to write these changes back to the PDF page.

If you want to get the parsed text of the page, you can use DynaPDF.Parser.ExtractText after you have called DynaPDF.Parser.ParsePage, which will return the text.

If you are particularly interested in this topic, please take a look at our new example Find and Replace Text.fmp12.

Let Randomness Decide

We have added three new algorithms in the Math section that generate random numbers. You can choose from the normal distribution, expotentail distribution and Poisson distribution. You can also specify the mean or lambda in each function to further influence the function. Math.Random.NormalDistribution then returns random numbers according to the Normal (or Gaussian) random number distribution. Math.Random.ExponentialDistribution a random non-negative floating-point number, distributed according to probability density function and Math.Random.PoissonDistribution gives you a non-negative integer value, distributed according to discrete probability function

In line with the topic of randomness, you now also have the option of randomly sorting the entries in your List and QuickList. The functions List.Shuffle and QuickList.Shuffle are available for this purpose.

Matrix

The new Matrix.IndexOfFirstValueMatching function allows you to determine the index of the first value in a matrix that matches a search. In the function, you first specify the matrix reference, then the column in which we want to search for the value, followed by the operator with which the subsequent value is to be matched. The operator can be =, !=, <, >, <=, >=, ≤, ≥, ≠, Prefix or Postfix. Optionally, we can specify a last parameter, the row in which we start the search.

Let's imagine we have a 3x3 matrix that looks like this.

231265
451204
668782

We now want to find a value in the second column that is greater than 100. We can use the corresponding script to do this.

Set Variable [ $Matrix ; Value: MBS("Matrix.New"; 3; 3) ] 
Set Variable [ $r ; Value: MBS("Matrix.SetRow"; $Matrix; 0; "23¶12¶65") ] 
Set Variable [ $r ; Value: MBS("Matrix.SetRow"; $Matrix; 1; "45¶120¶4") ] 
Set Variable [ $r ; Value: MBS("Matrix.SetRow"; $Matrix; 2; "66¶87¶82") ] 
Set Variable [ $r ; Value: MBS("Matrix.ConvertDataType"; $Matrix; "Number") ] 
Set Variable [ $res ; Value: MBS("Matrix.IndexOfFirstValueMatching"; $Matrix; 1; ">"; 100) ] 
Show Custom Dialog [ "Index Of First Value Matching" ; "The index is " & $res ] 

And this is the result:

The 120 corresponds to the criteria. As you can see in the script, you must first specify that the values within the matrix are numeric. Otherwise the values will be seen as text by default and the result may be incorrect.

FM.SQL

While we are on the subject of matrices, I would like to introduce you to another function. The function FM.SQL.ToMatrix allows you to write a result set received from FM.SQL.Execute to a matrix so that you can further process this result set with the matrix functions, for example.

Phidget

Last year we added the new component Phidget to the plugins. With the plugins you can control these small input/output devices of the Phidget brand. In this release, we have again added new functions to this component. On the one hand, we have the functions Phidget.SetTag and Phidget.GetTag with which we can set an additional tag, which we can then query again at a later time. This can be, for example, a data set ID that is linked directly to the Phidget.

We also have the new functions Phidget.EnableServerDiscovery and Phidget.DisableServerDiscovery. You can start a server discovery to find remote devices. A Phidget can be connected to a wireless hub that sends all data via Ethernet or Wifi to a computer in the local network. To connect to remote Phidgets, call the Phidget.EnableServerDiscovery with server type DeviceRemote. But for other uses you also have Pass none, deviceListener, Device, WWWListener, WWW, WWWRemote or SBC as types. To Disables the dynamic discovery of servers that publish their identity you need to call Phidget.DisableServerDiscovery.

CURL

Also new in the plugin are some CURL functions that refer to successes or failures in the transmission. You can now set a script or an expression that is called on success or failure in the transfer. For success, the functions CURL.SetSucceededEvaluate and CURL.SetSucceededScript are available. For failure, the functions CURL.SetFailedEvaluate and CURL.SetFailedEvaluate. In addition, we also have functions that give us information about the called script or expression.

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. With the functions JSON.MergePatch.FromDiff and JSON.JSONPatch.FromDiff functions, you can record these changes between two JSONs. Both have a different way of dealing with these changes as you can see here:

You can then apply the changes described by this patch to a JSON using the functions JSON.JSONPatch.ApplyPatch and JSON.MergePatch.ApplyPatch.

XL

While we're on the subject of JSON, let's move on to the XL area. Last year we had already added some functions to help you with form controls. In this release we are adding the XL.FormControl.JSON function. This returns a JSON that provides an overview of the individual form controls on a worksheet.

XML

A cool new function is the Converts XML to HTML function. Here you can convert the data from XML to HTML, which can then be displayed in a web browser, for example. Optionally, you can switch off the HTML header or pass an additional CSS with which you can customize the style of the output. Take a look at our new example XML to HTML.

While we are on the subject of converting to HTML. Since 13.3 we already have a function that converts matrices into HTML. This function, Matrix.HTML, has now also been given a parameter with which you can specify the CSS.

Identify the File type

With the Text.IdentifyData we can determine which data type our given text is. We read the first bytes of the file and decide which file type is may be. The supported formats are: PDF, JPEG, GIF, BMP, WebP, PNG, TIFF, GIF, SVG, ZIP, HEIF image, FileMaker database and Windows, MacOS and Linux executable. If you already know that the data is in a specific format such as hexadecimal or base64, you can specify the encoding as an optional parameter.

Here, the hexadecimal data function is used to check the type:

MBS( "Text.IdentifyData"; "89504E470D0A1A0A000000..."; "Hex" )

We have also added corresponding functions for the Files and Container areas. The Files.IdentifyData function then returns the corresponding type for a path. With the Container.IdentifyData function, we obtain the type of data in the container by specifying the container.

Mac and iOS

There are also new features for Mac and the iOS SDK

CNContact

If you are using a macOS contact database, you can save fmp:// URLs for the contacts. Then the user can click on the URL, open FileMaker and jump to the record. In FileMaker, use the CNContactStore.ContactsMatchingURL function to find the record using such a URL.

Code Folding

Did you know that you can activate code folding for your scripts with the goodies of the MBS FileMaker Plugin, so that you can e.g. fold in loops to display your script more clearly? With the new functions SyntaxColoring.SetCodeFoldingEnabled and SyntaxColoring.GetCodeFoldingEnabled you can now also set and query via script whether this goodie should be activated.

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

Claris FileMaker Plugin
23 01 24 - 08:22