In this article we want to introduce you the new functions from the MBS FileMaker Plugin in version 15.3.
SQL
First of all, I would like to introduce you to the new features for SQL. A very interesting function is the SQL.InternalSQLiteLibrary.Dump function. This function convert an SQLite database into UTF-8 text SQL statements that will exactly recreate that original database.
We also have new functions that allow you to activate extensions within SQLite. With SQL.InternalSQLiteLibrary.SetBase64ExtensionEnabled you can enable the base64 extensions to convert (binary) blobs and base64 text into each other. You can also use SQL.InternalSQLiteLibrary.SetCSVExtensionEnabled to activate the CSV extensions and thus have an implementation of an SQLite virtual table for reading CSV files. You also have the function SQL.InternalSQLiteLibrary.SetUUIDExtensionEnabled which activates a uuid extension. This SQLite extension implements functions that handling RFC-4122 UUIDs.
CURL
There is also a new function in the CURL area. With the function CURL.SetOptionSSLSignatureAlgorithms you set the TLS supported signature algorithms. Enter a colon-delimited list of signature scheme names in the parameters. You can also take a look at the CURL documentation. You can find this for the function here.
DynaPDF
A very popular feature in DynaPDF is the signing of documents. This allows the user to ensure that the document has not been changed in the meantime. A PDF document that is signed can sometimes have several signature fields. In this case, the first signature field without a value is selected for signing by default. With the new function DynaPDF.SetActiveSigField you can choose which field should be signed.
Files
If you are on a Mac or on Windows, you can print files with the new Files.PrintFile function without having to open the files manually. This function can save you time and automate processes. It opens the application associated with the file type and asks it to print the document. This requires cooperation from the applications and not all applications support this.
Java
We have also added three new functions for working with Java. You can use the Java.GetLoadedClasses function to output a JSON containing information about each class. This can look like this:
[
{
"name": "jdk.internal.misc.CarrierThread",
"methodCount": 0,
"fieldCount": 0,
"modifiers": 33,
"IsPublic": true,
"IsFinal": false,
"IsSuper": true,
"IsInterface": false,
"IsAbstract": false,
"IsSynthetic": false,
"IsAnnotation": false,
"IsEnum": false,
"IsModule": false,
"signature": "Ljdk/internal/misc/CarrierThread;",
"status": 0,
"IsVerified": false,
"IsPrepared": false,
"IsInitialized": false,
"IsError": false,
"IsArray": false,
"IsPrimitive": false
},
...
]
The Java.GetClassMethods function returns a JSON for the individual methods of a specific class. We specify the name of the class for which we want to retrieve the information in the parameters of the function. Here you can see an example JSON that the function returns:
[
{
"index": 0,
"name": "<init>",
"signature": "(Ljava/lang/String;Ljava/lang/Throwable;ZZ)V",
"modifiers": 4,
"IsPublic": false,
"IsPrivate": false,
"IsProtected": true,
"IsStatic": false,
"IsFinal": false,
"IsSynchronized": false,
"IsBridge": false,
"IsVarArgs": false,
"IsNative": false,
"IsAbstract": false,
"IsStrict": false,
"IsSynthetic": false,
"argumentsSize": 5,
"native": false,
"obsolete": false
},
...
]
Math
We have a few new functions for you in the Math section. First, we can now set and read the individual bits of a number that is internally converted into a binary value. For example, you can determine whether a number is even or odd without having to do a lot of arithmetic. Use the Math.GetBit function and look at the first bit (value 0) if the first bit is a 1, then the number is odd. if it is a 0, then the number is even.
Set Variable [ $bit1 ; Value: MBS("Math.GetBit"; 12; 0) ]
Set Variable [ $bit2 ; Value: MBS("Math.GetBit"; 13; 0) ]
Show Custom Dialog [ "First Bit" ; "12 => " & $bit1 & "¶13 => " & $bit2 ]
Using the Math.ClearBit function, we can clear a bit that we can specify in the parameters. This is then replaced with a 0. For example, if we look at the 5, then the binary code of the five is 101. If we now apply ClearBit to the 3rd bit (specified with the value 2), then we get a 1 as a return, because our representation of the binary number now looks like this: 001. So only the representation of the 1 remains.
Matrix
There is also an update in the Matrix area - we have expanded the possibilities for you. If you want to copy the content of a matrix to another matrix, you can use the new Matrix.CopyContent function.
You can now append a matrix to another matrix. This can look like this, for example. The first matrix is a 3x4 matrix with numbers as values and the second matrix is a 1x4 matrix with characters as values.
Let([
// new matrix
matrix = MBS("Matrix.New"; 3; 4);
// add some content
r = MBS( "Matrix.SetRow"; matrix; 0; "00¶01¶02¶03" );
r = MBS( "Matrix.SetRow"; matrix; 1; "10¶11¶12¶13" );
r = MBS( "Matrix.SetRow"; matrix; 2; "20¶21¶22¶23" );
// creates a second matrix
matrix2 = MBS("Matrix.New"; 1; 4);
r = MBS( "Matrix.SetRow"; matrix2; 0; "a¶b¶c¶d" );
// copy content of first matrix to second
r = MBS( "Matrix.Append"; matrix; matrix2 );
// output matrix to check
csv = MBS("Matrix.CSV"; matrix) ]
; csv)
From now on, you can also insert individual rows and columns in a matrix. To do this, use the Matrix.InsertColumnand Matrix.InsertRow functions.
Plugin
Would you like to be able to use your own functions across multiple FileMaker databases?
Then the Plugin.RegisterFunction function may be your perfect match. With this function you can register a custom function for your solution, which is accessible to all files.
In the parameter of this function, you first pass a number greater than 3 as the unique ID. You pass a name for the function as well as the prototype, i.e. how the function should be called with its parameters. Now follows the expression to be executed. Optionally, you can also specify the minimum and maximum number of parameters. This gives you space for optional parameters. An example of such a function definition could look like this:
Set Variable [ $r ; Value: MBS("Plugin.RegisterFunction";
123; // ID to use
"Concat"
"Concat(Value1; Value2)";
"Value1 & Value2";
2; // min and max parameters
2) ]
We have added three additional functions to help you with your work. The Plugin.CustomFunctionNames function lists the names of the CustomFunctions.
If your function takes a variable number of parameters, you can query the count With Plugin.CustomFunctionParameterCount and use Plugin.CustomFunctionParameter to return a specific parameter for the current function.
We can do something similar for script steps with the Plugin.RegisterScriptStep function. First, we specify the ID >3, the name and an XML that defines the script step. This is followed by the expression that is to be executed. Finally, there is a description to be displayed in the user interface.
MBS( "Plugin.RegisterScriptStep";
// internal ID. Must be unique
123;
// name of script step
"Concat";
// XML definition of parameters
"<PluginStep>
<Parameter Type=\"target\" Label=\"Destination\" ShowInLine=\"true\"/>
<Parameter Type=\"calc\" DataType=\"text\" ShowInline=\"true\" Label=\"FirstName\" ID=\"0\"/>
<Parameter Type=\"calc\" DataType=\"text\" ShowInline=\"true\" Label=\"SecondName\" ID=\"1\"/>
</PluginStep>";
// calculation
"MBS(\"Plugin.ScriptStepParameter\"; 0) & MBS(\"Plugin.ScriptStepParameter\"; 1)";
// description
"Concat two texts" )