| Components | All | New | MacOS | Windows | Linux | iOS | ||||
| Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old | |
Dictionary.ValueForKey
Queries value for the key.
| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
| Dictionary | 5.0 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
MBS( "Dictionary.ValueForKey"; DictionaryRef; Key ) More
Parameters
| Parameter | Description | Example |
|---|---|---|
| DictionaryRef | The reference number to the dictionary. | $dic |
| Key | The key to use. Keys are case sensitive. | "FirstName" |
Result
Returns value or error.
Description
Queries value for the key.As dictionary preserves data type, result can be empty, text, number, date, time, timestamp, container or boolean.
Returns an error, if key is not found. See Dictionary.Lookup to pass default value.
Examples
Serialize and unserialize with date and time:
# Create Dictionary
Set Variable [$dict; Value:MBS ( "Dictionary.Create" )]
# put date and time inside:
Set Variable [$r; Value:MBS ( "Dictionary.SetValueForKey"; $dict; "theTime"; Get ( CurrentTime ))]
Set Variable [$r; Value:MBS ( "Dictionary.SetValueForKey"; $dict; "theDate"; Get ( CurrentDate ))]
# Serialize this
Set Variable [$dictEncoded; Value:MBS ( "Dictionary.Serialize"; $dict )]
#Free dictionary
Set Variable [$r; Value:MBS ( "Dictionary.Release"; $dict )]
# Unpack it:
Set Variable [$newDict; Value:MBS ( "Dictionary.Deserialize"; $dictEncoded )]
# and get values
Set Variable [$TheTime; Value: MBS ( "Dictionary.ValueForKey"; $newDict; "theTime" )]
Set Variable [$TheDate; Value: MBS ( "Dictionary.ValueForKey"; $newDict; "theDate" )]
Show Custom Dialog [$TheTime & " " & $TheDate]
Set Variable [$r; Value:MBS ( "Dictionary.Release"; $newDict )]
Set Variable [$dict; Value:MBS ( "Dictionary.Create" )]
# put date and time inside:
Set Variable [$r; Value:MBS ( "Dictionary.SetValueForKey"; $dict; "theTime"; Get ( CurrentTime ))]
Set Variable [$r; Value:MBS ( "Dictionary.SetValueForKey"; $dict; "theDate"; Get ( CurrentDate ))]
# Serialize this
Set Variable [$dictEncoded; Value:MBS ( "Dictionary.Serialize"; $dict )]
#Free dictionary
Set Variable [$r; Value:MBS ( "Dictionary.Release"; $dict )]
# Unpack it:
Set Variable [$newDict; Value:MBS ( "Dictionary.Deserialize"; $dictEncoded )]
# and get values
Set Variable [$TheTime; Value: MBS ( "Dictionary.ValueForKey"; $newDict; "theTime" )]
Set Variable [$TheDate; Value: MBS ( "Dictionary.ValueForKey"; $newDict; "theDate" )]
Show Custom Dialog [$TheTime & " " & $TheDate]
Set Variable [$r; Value:MBS ( "Dictionary.Release"; $newDict )]
See also
- Dictionary.AddSQL
- Dictionary.Create
- Dictionary.Deserialize
- Dictionary.Lookup
- Dictionary.Release
- Dictionary.Serialize
- Dictionary.SetValueForKey
- Dictionary.ValueTypeForKey
Example Databases
Blog Entries
- MBS FileMaker Advent calendar - Door 23 - Dictionary
- Data structures in MBS Plugin
- Passing parameters via dictionary functions
This function checks for a license.
Created 12nd December 2014, last changed 15th February 2022