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  

Dictionary.KeysWithPrefix

Returns list with all keys matching prefix.

Component Version macOS Windows Linux Server iOS SDK
Dictionary 11.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "Dictionary.KeysWithPrefix"; DictionaryRef; Prefix )   More

Parameters

Parameter Description Example
DictionaryRef The reference number to the dictionary. $dic
Prefix The prefix text "JS."

Result

Returns list or error.

Description

Returns list with all keys matching prefix.
The order is random and defined by how the dictionary internally stores values.
See also Dictionary.Keys.

The postfix and prefix keys functions allows you to organize things in the dictionaries with e.g. dot notation. You may have entries like "person.123.firstname" and "person.123.lastname" and by using Dictionary.KeysWithPrefix you can look for "person.123." to find all keys starting with this prefix.

Examples

Try it:

Let([
// create a dicitonary
dic = MBS( "Dictionary.Create");
// fill in some values:
t = MBS( "Dictionary.SetValueForKey"; dic; "person.123.firstname"; "John" );
t = MBS( "Dictionary.SetValueForKey"; dic; "person.123.lastname"; "Miller" );
t = MBS( "Dictionary.SetValueForKey"; dic; "person.456.firstname"; "Tom" );
t = MBS( "Dictionary.SetValueForKey"; dic; "person.456.lastname"; "Smith" );
// and query keys:
r = MBS( "Dictionary.KeysWithPrefix"; dic; "person.123." )
]; r)

Example result:
person.123.lastname
person.123.firstname

See also

Release notes

Blog Entries

Created 18th July 2021, last changed 19th July 2021


Dictionary.KeysWithPostfix - Dictionary.List

Feedback: Report problem or ask question.




Links
MBS Xojo Chart Plugins

Start Chat