New version of bBox FileMaker plugin

One of my work/personal projects has been a FileMaker external plug-in for the Mac OS called bBox. The main push with this recently has was to include access to the Python scripting language. Previously, using bBox’s existing bBox_Shell function I could’ve called a Python script this way:

Set Variable [ $script; Value:"xs = 'He' + 'llo'; print xs # Complicated way to say hello" ]

Set Variable [ $res; Value:bBox_Shell( 0; "python -c \"" & $script & "\"") ]

Show Custom Dialog [ Title: "Python"; Message: $res; Buttons: “OK” ]

That’s definitely do-able. But you’ll likely have to reformat your scripts, and be careful about quoting or escaping characters. Alternatively, you could first ensure that your script had first been saved out to a file, perhaps by using FileMaker’s Export Records command.

But instead, I can now write something like the following from a FileMaker script:

Set Variable [ $script; Value:"# Complicated way to say hello. xs = 'He' + 'llo'

print xs "]

Set Variable [ $res; Value:bBox_PythonCompile( 0; $script ) ]

If [ $res = "" ]

Set Variable [ $res; Value:bBox_PythonExecute( 0 ) ]

Set Variable [ $ig; Value:bBox_PythonFinalize ]

End If

You may be wondering why it takes three function calls to execute such a simple script. There are three reasons for this. Most obviously, a script can be executed multiple times but only needs to be executed once. A related, but less obvious reason is the need to setup and then teardown the Python environment, which is significant for a short script like this. Finally, it allows the option of setting or retrieving Python variables from FileMaker, which can now be done with the bBox_PythonSetVar and bBox_PythonGetVar functions.

Tags: ,

Comments are closed.