In this article we want to introduce you the new functions from the MBS FileMaker Plugin in version 16.1.
Llama
AI is all the rage, and we're working to make as much of this technology available to you as we can. With Llama, we've added a new component to the plugin. This component provides functions that let you use a local LLM on your computer. This way, you can download a model, use it locally, and query it in a chat. You can learn more about how this works in our blog post Use Llama.cpp in FileMaker.

JSON
There are new features in the JSON section. For example, you can use the EnvironmentVariables.JSON function to display all environment variables from your operating system. An example for macOS might look like this:
{
"USER": "cs",
"COMMAND_MODE": "unix2003",
"__CFBundleIdentifier": "com.filemaker.client.pro12",
"PATH": "/usr/bin:/bin:/usr/sbin:/sbin",
"LOGNAME": "cs",
"SSH_AUTH_SOCK": "/private/tmp/com.apple.launchd.iXMjiPeWPN/Listeners",
"HOME": "/Users/cs",
"SHELL": "/bin/zsh",
"TMPDIR": "/var/folders/xv/4dhqggss03gc5r26p68b9pgc0000gn/T/",
"__CF_USER_TEXT_ENCODING": "0x1F5:0x0:0x0",
"XPC_SERVICE_NAME": "application.com.filemaker.client.pro12.243918009.243918015",
"XPC_FLAGS": "0x0"
}
The JSON.ToToon function is also new. It converts JSON to TOON. TOON stands for Token-Oriented Object Notation and is primarily used in the context of communication with AI. A conversion from JSON to TOON might look like this:

For more information on TOON and the new function, see the blog post Introducing TOON and JSON.ToToon in the MBS FileMaker Plugin
Phidget
We have added functions to the Phidget component that are essential for controlling LEDs. With the functions we have added, you can control LED arrays. Use the Phidget.SetLED function to set a single LED to the correct color at the correct location on the LED array by specifying the address and RGB color values in the parameters. If you want to set multiple LEDs on an LED array at once, use the Phidget.SetLEDs function. Here, you specify in the parameters, for example, the start and end addresses and the pattern you want. With Phidget.SetAnimation, you can also animate the LED array. A pattern can, for example, run across the array from left to right. You have the following options for moving the pattern: ForwardScroll, ReverseScroll, Randomize, ForwardScrollMirror or ReverseScrollMirror. If you have multiple animations, you can start them all simultaneously using Phidget.SynchronizeAnimations so that they run in sync. With the Phidget.StopAnimation function, you can disable the specified animation. The Phidget.ClearLEDs function turns off all LEDs in the array.
Files
We have added two new functions to the Files section. The Files.ApplicationPathWithBundleIdentifier function allows us to retrieve the path to an application by specifying the corresponding identifier in the parameters. It is possible that multiple applications have the same identifier. If you want to retrieve all paths, you can optionally specify a 1 in the parameters. You will then receive a list of all corresponding paths. Such a query might look like this:
Set Variable [ $fm ; Value: MBS( "Files.ApplicationPathWithBundleIdentifier";
"com.filemaker.client.pro12"; 1 ) ]
Show Custom Dialog [ "Path to FileMaker" ; $fm ]

This feature works on macOS.
The second new feature is the Files.OpenFiles function. It retrieves a list of open files from the FileMaker application. The list contains file paths for various files, such as open databases, open font files, various resource files for FileMaker or OS services, and, of course, temporary files.
Insert and Update in Databases
There are two new functions in the Matrix section. The Matrix.InsertOrUpdateRecords function allows us to update information in a FileMaker table using a matrix. In the parameters of this function, we first specify the matrix containing the data we want to use to update the table. Then we specify the name of the FileMaker file that contains the table we want to work with; if we leave this parameter blank, the function will search all open FileMaker files for the appropriate table. We then also specify the name of the table. Next comes a list of the field names for the fields to be modified in the table. Finally, we specify which field name must be compared with which array index so that the entries in the array can be assigned to the individual records for the update.
The situation is similar with the second function, Matrix.InsertOrUpdateRecordsToSQL, except that here we do not perform the update on a FileMaker database; instead, the update is performed via a connection to an SQL database. You can obtain a reference for such a connection from the SQL.NewConnection function, which you use to establish the connection to a database. With Matrix.InsertOrUpdateRecordsToSQL, we first specify the Matrix reference, then the SQL reference, followed by the table name and the fields. Finally, we again define the key field mapping. That might look like this:
Set Variable [ $InsertFields ; Value: "Key¶TextField¶NumberField¶DateField¶TimeField¶
TimestampField¶ContainerField¶Description" ]
Set Variable [ $result ; Value: MBS("Matrix.InsertOrUpdateRecordsToSQL"; $sql; $Connection; "Test";
$InsertFields; "Key=0") ]
In the FM section, we have also added very similar functions: FM.SQL.InsertOrUpdateRecordsToSQL and FM.SQL.InsertOrUpdateRecords. The difference from the matrixfunctions is that, in this case, we do not have data in a matrix that we want to insert into a corresponding database; rather, the data to be inserted comes from an SQL query against our FileMaker database.
# Load records into a stored SQL result and insert/update into other table
Set Variable [ $SelectSQL ; Value: "SELECT PrimaryKey, TextField, NumberField, DateField, TimeField,
TimestampField, ContainerField, Description FROM Source" ]
Set Variable [ $InsertFields ; Value: "Key¶TextField¶NumberField¶DateField¶TimeField¶
TimestampField¶ContainerField¶Description" ]
#
Set Variable [ $sql ; Value: MBS("FM.SQL.Execute"; Get(FileName); $SelectSQL) ]
#
If [ MBS("IsError") ]
Show Custom Dialog [ "Error: " & $sql ]
Else
Set Variable [ $result ; Value: MBS("FM.SQL.InsertOrUpdateRecords";
$sql; Get(FileName); "Dest"; $InsertFields; "Key=0") ]
If [ MBS("IsError") ]
Show Custom Dialog [ "Error: " & $result ]
Else
Show Custom Dialog [ "Records updated." ; $result ]
End If
End If
#
Set Variable [ $r ; Value: MBS("FM.SQL.Release"; $sql) ]





