Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
10.1
10.2
10.3
10.4
10.5
11.0
11.1
11.2
11.3
11.4
Statistic
FMM
Blog
FM.CF
Calls a custom function given the name with FileMaker values.
Component |
Version |
macOS |
Windows |
Linux |
Server |
iOS SDK |
FM Dictionary
|
11.3 |
✅ Yes
|
✅ Yes
|
✅ Yes
|
✅ Yes
|
✅ Yes
|
MBS( "FM.CF"; DictionaryRef; Name; Parameters... )
More
MBS(
"FM.CF"; /* Calls a custom function given the name with FileMaker values. */
$DictionaryRef; /* The reference number to the dictionary.
We prefer to use
Dictionary.CreateNamed to create a special dictionary named "CF" and refer it globally with that name.e.g. "CF" */
$Name; /* The name of the function.e.g. "test" */
$Parameters...) /* Value to pass as parameter. */
Less
Parameters
Parameter |
Description |
Example |
DictionaryRef |
The reference number to the dictionary.
We prefer to use Dictionary.CreateNamed to create a special dictionary named "CF" and refer it globally with that name. |
"CF" |
Name |
The name of the function. |
"test" |
Parameters... |
Value to pass as parameter. |
|
Result
Returns result or error.
Description
Calls a custom function given the name with FileMaker values.
This allows you to store expressions for custom functions in a MBS dictionary, so you can refer to them by name.
Parameters are passed to the function preserving the data type.
Please pass as many parameters as needed.
If the function needs more parameter, undefined values are used to fill up.
If the function needs less parameters, additional ones are dropped.
There is no limit in the number of parameters for MBS Plugin here.
Recursion is limited by FileMaker with about 200 deep. The plugin has a hard limit of 50000 for recursion, but before that, the FileMaker engine will report running out of memory.
The dictionary must contain the given Name as key and as value a valid FileMaker expression. This expression may have lines on the beginning with /// to name variables, one line per variable name.
The expression to evaluate can be in local language of FileMaker Pro or english.
For Server it must always be in english.
Two special variables are always defined: FunctionName and DictionaryRef with the values filled with the parameters you passed above.
If you like to have a function with variable parameters, you can use ParameterIndex and ParameterCount in your calculation. To query plugin parameter values, we have MBS("FM.CF.Parameter"; index) to query them.
This function takes variable number of parameters. Pass as much parameters as needed separated by the semicolon in FileMaker.
Please repeat Parameters parameter as often as you need.
Examples
Call Concat function with two parameters:
MBS( "FM.CF"; "CF"; "Concat"; "Hello"; "World")
Call a function and pass field value, calculation and hard coded value:
MBS( "FM.CF"; "CF"; "Test"; MyTable::MyField; Get(AccountName); "Hello"; Round($Total + ($Total * $taxRate); 2) )
Create dictionary, add a function and
# create environment
Set Variable [ $CF ; Value: MBS("Dictionary.CreateNamed"; "test" ) ]
#
# Register one function. Replacing older one with same name
Set Variable [ $FunctionName ; Value: "Greet" ]
Set Variable [ $Body ; Value: "/// Name¶¶\"Welcome \" & Name & \"!\"" ]
Set Variable [ $r ; Value: MBS( "Dictionary.SetValueForKey"; "test"; $FunctionName; $Body) ]
#
# now run it
Set Variable [ $r ; Value: MBS("FM.CF"; "test"; "Greet"; "Peter") ]
Show Custom Dialog [ "Result" ; $r ]
#
# cleanup
Set Variable [ $r ; Value: MBS("Dictionary.Release"; "test") ]
Defines a recursive function Count, which calls itself:
MBS( "Dictionary.SetValueForKey";
"CF"; // dictionary reference
"Count"; // function name
"/// Value¶" &
"If ( Value > 0; \"a\" & MBS(\"FM.CF\"; DictionaryRef; FunctionName; Value-1); \"x\")" )
See also
Release notes
- Version 11.4
- Version 11.3
- Added FM.CF function to run custom functions defined in a database table and managed via Dictionary functions.
- Added recursion limit for FM.CF with 50000 as limit, but after about 200 deep FileMaker will report running out of memory.
Example Databases
Blog Entries
Created 10th June 2021, last changed 13th July 2021
FM.Beep
-
FM.CF.Parameter
Feedback: Report problem or ask question.