SBM ModScript Reference → Programming SBM ModScript → Object Types → Dictionary
A class for supporting dictionary objects in scripts that are converted from SBM AppScript to SBM ModScript. A dictionary is a case sensitive key-value container. In general, use ChaiScript's Map instead.
Dictionary can be iterated using ChaiScript's for loop. See example below.
Dictionary(): Creates a dictionary object.
Optionally, use CreateObject() with "Scripting,Dictionary".
Variant& operator[]( key ): Accesses value at location key. Inserts value if not found.
Variant& at( key ): Accesses value at location key. Throws exception if not found.
uint64_t size(): Returns the count of items in the container.
bool empty(): Returns if the container is empty.
void clear(): Removes all items from the container.
uint64_t count( key ): Returns 1 if key found inside the container; otherwise, 0.
void insert( Dictionary_Pair entry ): Inserts entry into the container. Dictionary_Pair is the data type that represents an entry.
void Add( key , value ): Adds an entry to the container. Throws if key is already in the dictionary.
bool Remove( key ): Removes the entry with key. Returns true if found.
void RemoveAll(): Removes all items from the container.
int Count(): Returns the count of items in the container.
Variant& Item( key ): Accesses value at location key. Inserts value if not found.
void Key( key ): Inserts key if not found.
void SetKey( keyOrig , keyNew ): Moves entry from keyOrig to keyNew.
bool Exists( key ): Returns true if key is found.
Vector Keys(): Returns a Vector of keys.
Vector Items(): Returns a Vector of values.
var dict = Dictionary(); dict.Add( "key1", "val1" ); dict.Add( "key2", "val2" ); dict.Add( "key3", 3 ); for ( entry : dict ) { Ext.WriteStream( "${entry.first()}: ${entry.second()}\n" ); }
Copyright © 2007–2018 Serena Software, Inc., a Micro Focus company. All rights reserved.