Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
Dictionary.Create
Creates a new dictionary.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
Dictionary | 5.0 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
Key | Optional, a key. | Optional | |
Value... | Optional, a value. | Optional |
Result
Returns dictionary reference number or error.
Description
Creates a new dictionary.Dictionaries are hash maps, so lookup is very fast (often faster than search in your FileMaker database). You can use them for storing parameters or lookup tables.
Optionally you can pass keys and values as parameters to this function.
If you looked for associative arrays, you are right here.
Dictionaries can have multiple million of entries without problems. Just be aware of FileMaker's standard loop/recursion limit of 50000, which can be raised with SetRecursion function.
This function takes variable number of parameters. Pass as much parameters as needed separated by the semicolon in FileMaker.
Please repeat Value parameter as often as you need.
Examples
Build a dictionary in a calculation:
Let ( [
/*
Create new Dictionary
*/
param = MBS( "Dictionary.Create" );
/*
Fill in parameters
*/
r1 = MBS( "Dictionary.SetValueForKey"; param; "text"; Pass Parameters with Dictionary::TextField );
r2 = MBS( "Dictionary.SetValueForKey"; param; "number"; Pass Parameters with Dictionary::NumberField);
r3 = MBS( "Dictionary.SetValueForKey"; param; "date"; Pass Parameters with Dictionary::DateField);
r4 = MBS( "Dictionary.SetValueForKey"; param; "time"; Pass Parameters with Dictionary::TimeField);
r5 = MBS( "Dictionary.SetValueForKey"; param; "timestamp"; Pass Parameters with Dictionary::TimeStampField);
r6 = MBS( "Dictionary.SetValueForKey"; param; "container"; Pass Parameters with Dictionary::ContainerField)
/*
return dictionary
*/
] ; param )
Build a dictionary with given Keys and Values:
MBS("Dictionary.Create"; "FirstName"; $FirstName; "LastName"; $LastName; "City"; $City; "Phone"; $Phone; "Email"; $Email)
Test script to look for duplicate UUIDs:
Set Variable [ $dic ; Value: MBS( "Dictionary.Create") ]
Loop
Set Variable [ $uuid ; Value: Get(UUID) ]
If [ MBS("Dictionary.HasKey"; $dic; $uuid) ]
Show Custom Dialog [ "Duplicate!" ; $uuid ]
Exit Loop If [ 1 ]
End If
Set Variable [ $r ; Value: MBS( "Dictionary.SetValueForKey"; $dic; $uuid; $uuid ) ]
End Loop
Set Field [ test::test ; MBS( "Dictionary.Keys"; $dic ) ]
Set Variable [ $r ; Value: MBS( "Dictionary.Release"; $dic ) ]
See also
- Dictionary.Count
- Dictionary.CreateNamed
- Dictionary.KeysWithPostfix
- Dictionary.KeysWithPrefix
- Dictionary.Serialize
- Dictionary.SetValueForKey
- Dictionary.ToJSON
- Dictionary.ToMatrix
- Dictionary.ToText
- Dictionary.ToXML
Release notes
- Version 8.1
- Added Dictionary.CreateNamed function.
Example Databases
Blog Entries
- Data structures in MBS Plugin
- Data structures in FileMaker with MBS Plugins
- MBS FileMaker Plugin 5.1 for OS X/Windows
- Passing parameters via dictionary functions
This function checks for a license.
Created 12nd December 2014, last changed 2nd November 2021