Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
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 |
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
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. | Optional |
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.
See also CF function for shorter access.
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
- CF
- Dictionary.Create
- Dictionary.CreateNamed
- Dictionary.Release
- Dictionary.SetValueForKey
- FM.CF.Parameter
Release notes
- Version 14.1
- Version 11.4
- Added FM.CF.Parameter function.
- 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
- MBS FileMaker Plugin, version 14.1pr2
- New in MBS FileMaker Plugin 11.3
- Neues MBS FileMaker Plugin 11.3
- MBS FileMaker Plugin 11.3 - More than 6500 Functions In One Plugin
- MBS FileMaker Plugin, version 11.3pr7
- MBS @ FMTraining.TV
- MBS FileMaker Plugin, version 11.3pr4
- Custom Functions stored in a database
- MBS FileMaker Plugin, version 11.3pr3
This function checks for a license.
Created 10th June 2021, last changed 10th February 2024