« Show Live Photos in y… | Home | New in the MBS Xojo P… »

News about the MBS FileMaker Plugin 10.2

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

FileMaker
We have some new functions that help you to work with the FileMaker layout IDs. You can get the ID of the current layout with FM.CurrentLayoutID function. If you have a layout name, you find the matching layout ID with FM.LayoutNameForLayoutID function. Other way you can query the layout ID to a given layout name with FM.LayoutIDForLayoutName function and list all layout names with FM.LayoutNames.
This is analog to our script functions to query ID or name for scripts, see FM.ScriptIDForScriptName and FM.ScriptNameForScriptID.

Matrix
In the new version we add a lot of function for the work with the data structure named Matrix. With the Matrix.Add function we can add a value to a range of cells in the matrix. If we want to change the entries by a formula we can use the new Matrix.Evaluate function.

If we want to copy a column or a row from one matrix to another or to another place in the same matrix, we can use the functions Matrix.CopyColumn and Matrix.CopyRow. In the parameters we first specify the matrix from which we want to copy data, followed by the row or column to be copied. The next parameters are the target matrix and the target row or column.

We can now also use the functions Matrix.SetColumnName and Matrix.SetRowName to set column or row names. These can then be read out individually with Matrix.GetColumnName and Matrix.GetRowName. With Matrix.GetColumnNames and Matrix.GetRowNames we get a list of the columns or row names. Whenever you specify a column or row index, you can now pass the name instead. Please make sure the names are unique.

List and QuickList
The new QuickList.CountValuesMatching and List.CountValuesMatching functions counts the entries that matching to a given operation. For Example: MBS( "QuickList.CountValuesMatching"; list; "<"; 4 ) counts the entries that are less than 4.

The QuickList.SortWithEvaluate and List.SortWithEvaluate functions sorts the list with using an expression to evaluate.
The QuickList.IndexOfFirstValueMatching and List.IndexOfFirstValueMatching function gives us the index of the first matching record by a given operation.
All three functions exist for Lists as well as for QuickList component.

CURL
With the new CURL.GetHeaderAsJSON function we can query the header entries of a HTTP query performed with our CURL functions. It is only for HTTP headers or headers in similar format.

For example: MBS( "CURL.GetHeaderAsJSON"; $curl ) can return a JSON like this one:

{
  HTTP-Version:   "1.1",
  HTTP-ResponseCode:   "200",
  HTTP-ResponseMessage:   "OK",
  Date:   "Sat, 25 Apr 2020 10:37:35 GMT",
  Server:   "Apache/2.4.41",
  Upgrade:  "h2c",
  Connection:   "Upgrade",
  Last-Modified:   "Thu, 28 Feb 2013 16:43:55 GMT",
  ETag:   ""\726-4d6cb98aca8c0\"",
  Accept-Ranges:  "bytes",
  Content-Length:   "1830",
  Content-Type:   "text/plain",
  Content-Language:   "en"
}

With the function CURL.LoadLibrary and a native path of the library file, that we set in the parameters, we can load a custom CURL library. For example to support HTTP/2. For the CURL library built-in to the plugin, we enabled Keberos authentication for Windows version.

JSON
The JSON component got two new functions. With JSON.AddArrayToArray we can add an array to an existing array.

In this example we Create two Arrays Then we add Array2 to Array1 by the new function

#Create array 1
Set Variable [ $Array1 ; Value: MBS( "JSON.CreateArray" ) ]
Set Variable [ $Array1 ; Value: MBS( "JSON.AddNumberToArray"; $Array1; 2; 4; 6 ) ]
#Create array 2
Set Variable [ $Array2 ; Value: MBS( "JSON.CreateArray" ) ]
Set Variable [ $Array2 ; Value: MBS( "JSON.AddStringToArray"; $Array2; "Hello"; "World" ) ]
#Add them
Set Variable [ $BothArrays ; Value: MBS( "JSON.AddArrayToArray"; $Array1; $Array2 ) ]




If we want to sort an array with a special expression, the JSON.SortWithEvaluate function helps us to do that. You define the expression in the parameters to define the sort order, e.g. sort by text or by number, sort ascending or descending.

SQL
But not only in the component JSON you can find functions that work with JSON. Also in our SQL component you now get the opportunity to pass the parameters via JSON with the help of the SQL.SetParamsWithJSON function and get them with the SQL.GetParamsAsJSON function. Fields and records can also be returned with the functions SQL.GetFieldsAsJSON as JSON object and SQL.GetRecordsAsJSON as JSON Array.

XML
With the new function XML.Compact you can get a compact XML document, the opposite of XML.Format function. The function removes spaces, so that we can save network bandwidth for transmitting and disk space for the storage.


SSH
With SSH.Tunnel.SetKeepAlive we get a function to avoid TCP/IP timeouts. If we set the KeepAlive status to 1, TCP keep alive probes will be sent to avoid TCP/IP timeouts. Whether the status is one, we can check with SSH.Tunnel.GetKeepAlive.

Mutex
A mutex allows the synchronization of file, memory or device access by two FileMaker processes. e.g. that client and server running on same computer. At first we can create a mutex by name. The name of the mutex should be a simple text, but unique, so we recommend reverse domain notation.

Set Variable [ $mutex ; Value: MBS( "Mutex.Create"; "de.monkeybreadsoftware.test" ) ]

When we no longer need the mutex, we can free up the memory with the call of Mutex.Free.

To prevent the simultaneous accesses from interfering with the reading and writing of data, the data flow can be locked by one of the applications, so that they can’t override or be readable for a special time. This avoids the inconsistencies in the data. With the function Mutex.TryLock we lock the process. If it was successful we get 1 as return. If the mutex is already locked, we get 0 as return. Only one application can lock the mutex at the same time.

To unlock the mutex we call Mutex.Unlock later.

With the function Mutex.List you can list all Mutex reference numbers. With Mutex.Name we can find the corresponding name for each entry in the list.

ECKey
The new version of the plugin includes two new functions to make working with ECKeys easier. You can use the ECKey.CanSign function to determine whether it can be used for signing.
The other function, ECKey.Valid, verify if a private and/or public key is valid.

GMImage
With the new function GMImage.ReadFromContainer you can read a single image frame of the current object and set different options before reading an image. The options are the geometry that defines the height and width of an image, the color depth and the codec that should to use to read the file.

DynaPDF
The component DynaPDF has also some new features for you.
You can now generate figures with gradients in DynaPDF. For this purpose you can use the functions DynaPDF.CreateRadialShading and DynaPDF.CreateAxialShading. The shading is only displayed after the DynaPDF.ApplyShading function has been called. The example shows you how to place a tube color gradient on a PDF page.

Set Variable [ $r ; Value: MBS( "DynaPDF.AppendPage"; $PDF ) ]
Set Variable [ $width ; Value: MBS( "DynaPDF.GetPageWidth"; $PDF ) ]
Set Variable [ $height ; Value: MBS( "DynaPDF.GetPageHeight"; $PDF ) ]
Set Variable [ $StartX ; Value: $width/2 ]
Set Variable [ $StartY ; Value: $Height/2 ]
Set Variable [ $radial ; Value: MBS( "DynaPDF.CreateRadialShading"; $PDF; $StartX; $StartY; 20; $StartX+50; $StartY+50; 30; 1; MBS(DynaPDF.RGB; 0; 0; 255); MBS(DynaPDF.RGB; 255; 0; 0) ) ]
Set Variable [ $r ; Value: MBS( "DynaPDF.ApplyShading"; $pdf; $radial ) ]


We append a page to the document and determine the center coordinates of the page by height and width. We save it in $StartX and $StartY. We define these coordinates as the starting point for our shading. Then we set the radius of our first circle to 20 pixels and take the coordinates and radius for the second circle. The gradient is displayed between these two circles. The next parameter defines the position of the shading center. A value of 1 determines the exact center between the start and end point of the shading. Smaller values shift the shading center in direction to the start circle, greater values to the end circle. After that we define the colors of the gradient. Finally, we display the gradient by using the DynaPDF.ApplyShading function in the document.

 

For form fields we can define images for buttons in forms with the DynaPDF.AddButtonImage function.

With this plugin version you can add a signature field to display the status of the digital signature to proof the PDF has not been modified after creation. Check out our functions to sign a PDF with a private key: DynaPDF.SaveAndSignFile.

XL
The XL component, which provides functions for working with Excel documents, gets new features in the new version, too. You can set the calculation mode with the XL.Book.SetCalcMode function and query the current calculation mode with the XL.Book.GetCalcMode function.

You can check if a field contains styled text with the XL.Sheet.CellIsStyledText function and read it with XL.Sheet.CellReadStyledText function or write it with the XL.Sheet.CellWriteStyledText function into the cell. We translate between the Excel styles and FileMaker styles as well as we can. The formatting of the text can be done with Filemaker's own functions as it is show in the example here:

Set Variable [ $text ; Value: TextColor ( red; RGB ( 255 ; 0 ; 0 ) ) & " " & TextColor ( "blue"; RGB (0 ; 0 ; 255 ) ) ]
Set Variable [ $r ; Value: MBS( "XL.Sheet.CellWriteStyledText"; $BookRef; $sheet; $row; $col; $text ) ]




With the new functions XL.Sheet.RemovePicture and XL.Sheet.RemovePictureByIndex functions we can now remove images from cells. The two functions are different in how to find the image that should be removed. In the first function we specify it by row and column while the second function locates the image via the index.

Progress Dialog under Windows

For the Progress Dialog under Windows you can set the icon of a window. To do that you use the ProgressDialog.SetTitleIcon function. In the example you see how you can use this function.

# load image
Set Variable [ $image ; Value: MBS( "GMImage.NewImagesFromContainer"; ProgressDialog::Icon) ]
# set icon
Set Variable [ $r ; Value: MBS( "ProgressDialog.SetTitleIcon"; $image) ]
# later free it
Set Variable [ $r ; Value: MBS( "GMImage.Release"; $image) ]


The function GMImage.NewImagesFromContainer helps you to read the image from the container.

New functions for Mac users and iOS
The MBS FileMaker Plugin in version 10.2 offers some more new features for Mac users and for iOS

ImagePicker
ImagePicker.MediaMetadata is a new function in the ImagePicker component for iOS. The function gives us the information about the media we work with in the image picker as a JSON object. Because the data is structured, a better automatic processing is possible.

Web Viewer
With the new function WebView.InstallUserMediaAccess we can enable the media access. In that way we can release the camera(2), microphone(1) or the display(4) to be able to use it with web applications. We specify the corresponding number in the parameters of the function. If we want to enable more than one media we can add the numbers of the individual sources. The function must called only once on the start of FileMaker to enable the user media access.

Color Panel
The ColorPanel component also gets two new functions. With the ColorPanel.GetVisible function we can test whether the Color Panel is visible. If the color panel is visible, we get 1 as return. The second function, ColorPanel.SetVisible, sets the visibility of the color panel. So if we pass 1 in the parameters it is shown and if we pass 0 it is hide.

Before, there were also functions then made it possible to show and hide it. But with the new function ColorPanel.SetVisible, you can pass a boolean value to make scripts easier to use. For example, you can show the color panel when it is hidden and hide it when it was shown before.

HotKey
There are also innovations for Hot Keys. You can now restrict Hot Keys to the script workspace with the function HotKey.SetScriptWorkspaceOnly or set Hot Keys permanently with the HotKey.SetPermanent function. This helps to automate actions in the Script Workspace in relation to our custom context menu commands there. In addition, the new plugin version also offers functions to check whether a hotkey is permanent or limited to the script area.

See Russell Watson's fmAutoMate for how to install commands to automate FileMaker and use the permanent hotkeys.

SyntaxColoring
For many years now we have our variable check, for the simplification of writing scripts, in our plugin. By default the variables in scripts with up to 2000 lines are checked. We look up to 500 lines for variable declaration by default. You can now decide how you want to change this limit. To do that, call the SyntaxColoring.CheckVariableDeclaration.SetLimits function and pass numeric parameters that define how many lines to look up and how long a script may be to not be checked at all.

We have set the limit to 500 lines because more than 500 controlled lines make the workspace slower. With the SyntaxColoring.CheckVariableDeclaration.GetLimits function you can query the status of these parameters.

Our font size adjustment in the script workspace now works much better and includes values in the script line.

AVPlayer
The AVPlayer component has some new features. With the AVPlayer.AddView we create a new player view and use it for the current player to display video data. With the AVPlayer.SetControlsStyle function you can set the control style to None, Inline, Floating or Minimal or set with AVPlayer.SetAutoResizingMask the resizability of the player. With the function AVPlayer.SetVisible we can also show or hide the player view. There are also other functions with which you can set the focus on the player view (AVPlayer.SetFocus), set the tag (AVPlayer.SetTag) or show or hide the frame stepping button (AVPlayer.SetShowsFrameSteppingButtons) or the FullScreen button (AVPlayer.SetShowsFullScreenToggleButton). For the individual set functions there are also suitable functions that query these attributes.

We hope you will also find some interesting new features. We wish you a lot of fun with MBS FileMaker Plugin Version 10.2. If you need a license or have any questions, please contact us. by Stefanie Juchmes
19 05 20 - 12:44