We are pleased to release bBox version 0.99 for Claris® FileMaker® on macOS and Linux with new NodeJS and Python 3 integration, and M1 Apple silicon support for GraphicsMagick image processing and JQ JSON parsing functions.
About bBox Plug-in For FileMaker
bBox is a free utility plug-in to extend Claris FileMaker solutions to easily use macOS and Linux code libraries and functions from Python, JavaScript, PHP, Ruby, AppleScript, C/C++, Bash/sh, XPath, and SQLite. Also included is a demo file with more than 210 examples of how you can put bBox functions to work for you.
bBox is available on macOS and Linux, and runs with either FileMaker Pro or FileMaker Server. Here’s what FileMaker Magazine had to say about bBox version 0.99:
Update: Version 0.99.8 released
This build has the following changes over what’s mentioned below:
- bBox_JavascriptNode can now use the alternate path (+16) mode
- version string regression in macOS .plist file fixed
- bBox_PythonGetVar now sets error code if an unknown variable name is used
- initialization bug in bBox_Grep fixed
If the alternate path mode is used, bBox_JavascriptNode will use the following paths for the NodeJS executable. In particular, this is useful if you want to run the NodeJS based code locally on macOS without a copy of FileMaker Server being installed.
- Linux: /usr/bin/node
- macOS: /usr/local/bin/node
New and Improved in bBox v0.99
Some of the improvements and changes in bBox v0.99 include:
- bBox_JavaScriptCore function for FileMaker Server-side JS execution on Linux
- M1 / Apple silicon binaries for JQ and GraphicsMagick
- Ubuntu 20 compatibility; FileMaker Pro/Server 19.5 compatibility
- bBox_Python functions now use Python 3 (installation required)
- parameter replacement now supports zipped folders
- GraphicsMagick updated to version 1.3.37
- fix for fatal exception during high CPU usage of JQ function
- error handling fixed if attempting to use SQLite before initializing connection
- tested with FileMaker 19.5 on macOS and Linux
Apple Silicon
The macOS version of bBox is now a fully “universal” binary, with both Intel and Apple silicon executables in the same plug-in file. Previously, the JQ and GraphicsMagick functions were reliant on Rosetta emulation when running on Apple silicon-based systems. JQ is now also using the latest development version on macOS. JQ on Ubuntu will continue to use the OS-installed version, which is typically version 1.5.
JQ is useful for JSON handling. And it’s pretty fast:
Additionally, the Linux version of the bBox 0.99 plug-in is compatible with Ubuntu 20 and the upcoming FileMaker 19.5 release.
Added Parameter Expansions
It isn’t uncommon to need copies of files stored as FileMaker container data with bBox functions. To facilitate this, many functions can convert container file references into file paths after first creating temporary copies of the file data. One big change with this version is that also includes unzipping zip files.
If we have a .zip file containing file_a and file_b stored in a container, here’s an example of what that might look like if we recursively list the contents of it. We have to use a mode of 64 to enable the unzip feature:
bBox_Bash( 64; "ls -R $1"; "-s"; [example.zip] )
That will return the following output if using the sample file in the bBox Demo file:
folderaddedtozip
/private/tmp/bBox_posix_uqqkFetiw.bin/folderaddedtozip:
file_a
file_b
Where did “folderaddedtozip” come from? That was the name of the folder that was originally zipped up, and may have no relation to the name of the .zip file. The unzipping process however has dutifully recreated that original folder and its contents inside the parent folder, which is using a randomized name.
Note that best practice normally is to put double-quotes around path parameters, but I’ve omitted those here to keep the example simpler. Also, if the files are large or confidential, you may want to delete the parent directory (the one with randomized name) when done, as it may be up to three days before the OS purges the contents of the /tmp directory.
New NodeJS Integration on macOS and Linux
Although the existing bBox_JavaScript function or the bBox_WebView functions work well on macOS, there was no convenient method for JavaScript execution on Linux servers. Additionally, although bBox_JavaScript is server-side compatible on macOS servers, that method lacks access to the JavaScript DOM found in a browser, which prevents usage of many existing JavaScript libraries.
Now, bBox v0.99 uses a new method of execution, compatible with both macOS and Ubuntu Linux servers. This leverages the extremely popular NodeJS Javascript runtime included with FileMaker Server installations. Since this is a work in progress, the parameters may change slightly in a later release.
Let’s start with something really simple, the classic Hello, world! example.
bBox_JavaScriptNode (0; ""; TextEncode ("console.log ('Hello, world!');"; "utf-8" ; 0))
Since the script is expected to be given as container data, we have to wrap the script with the TextEncode function. Also remember that this must be executed on a system with FileMaker Server installed, so you’ll probably want to wrap the above calculation in a script that you call using PSOS (Perform Script On Server)
Now we’ll try something a bit harder. Although we can’t recommend modifying FileMaker Server’s NodeJS installation to add modules, the bBox_JavaScriptNode function allows you to include packages saved into a container field.
Here’s an example of using CommonJS style of module, which you can also find in the bBox Demo file. It will take zero or more numeric parameters and return their sum.
We’ll first need to create a file in a container field (or a path on the server’s file system) with the necessary module file:
exports.addArgs = function (inputArgs) {
const argCount = inputArgs.length;
var numArg = "";
var sum = 0.0;
for (var i=0; i < argCount; i++) {
numArg = inputArgs[i];
if (isNaN (numArg)) {
console.log ("non-numeric parameter: " + numArg)
} else {
sum += parseFloat (numArg);
}
}
return sum;
}
Next, we need the main script to pull out the numeric parameters and pass them to the function in the module:
const modulePath = process.argv[2];
console.log ("modulePath=%s",modulePath);
var addParametersModule = require (modulePath);
const numberArgs = process.argv.slice(3);
sum = addParametersModule.addArgs (numberArgs);
console.log (sum);
Now to call this from FileMaker, where square brackets denote container references, followed by the numbers to add:
bBox_JavaScriptNode (0; ""; [addParameters.js]; [addParametersModule.js]; 5; 7; 3)
As the first line of output we get the path used for the module, followed by the sum. Since container field references are by default expanded to a randomized file name, the module name will vary with each run.
modulePath=/private/tmp/bBox_posix_sQE3MwOLn.bin
15
Improved Python 3 Support
Python 3 support already existed with the bBox_Python3Run script step, but the more tightly integrated bBox_PythonExecute and its related function were still relying on older Python 2.7-based libraries. Version 0.99 of bBox now supports Python Foundation’s version of Python 3 — currently Python 3.10 on macOS, and Python 3.8 on Ubuntu Linux.
bBox v0.99 Availability and Pricing (It’s a free download!)
bBox v0.99 is available for immediate download from Beezwax Datatools.