Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Guides   Examples
New in version: 7.5   8.0   8.1   8.2   8.3   8.4   8.5   9.0   9.1   9.2    Statistic  


Stores value for given key.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
Dictionary 5.0 Yes Yes Yes Yes Yes
MBS( "Dictionary.SetValueForKey"; DictionaryRef; Key; Value )   More


Parameter Description Example value
DictionaryRef The reference number to the dictionary as returned by Dictionary.Create function. $dic
Key The key to use. Keys are case sensitive. Also keys must be text and should be single line. "FirstName"
Value The new value. Supported data types include empty, text, number, boolean, container, time, timestamp and date. "Hello World"


Returns OK or error.


Stores value for given key.
Data type is preserved, so you can even store containers in the dictionary.
Keys should be text and are handled case sensitive.


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 )

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 )]

See also

Example Databases

Blog Entries

Created 12nd December 2014, last changed 22nd February 2016

Dictionary.SetQuickList   -   Dictionary.SetVariables

Feedback: Report problem or ask question.

MBS Xojo PDF Plugins