IVZDataDictionary.Add

Syntax

Add(Key: String; Value: Variant);

Parameters

Key. Key of the element to be added.

Value. New dictionary element.

Description

The Add method adds a new element to dictionary.

Comments

To remove element, use the IVZDataDictionary.Remove method.

Example

Add a link to the Visualizators system assembly.

Sub UserProc;
Var
    Dictionary: IVZDataDictionary;
    i: Integer;
   Key: Variant;
Begin
    // Create a new dictionary and add elements to it
    Dictionary := New VZDataDictionary.Create;
    Dictionary.Add("Key 1"25);
    Dictionary.Add("Key 2""Element value");
    Dictionary.Add("Key 3"2.4);
    // Remove element in position with the set key
    Dictionary.Remove("Key 3");
    // Output dictionary size
    Debug.WriteLine("Dictionary size: " + Dictionary.Count.ToString);
    // Output a list of all keys and values of dictionary elements
    Debug.WriteLine("Dictionary:");
    For i := 0 To Dictionary.Count - 1 Do
       Key := Dictionary.AllKeys.Item(i);
        Debug.WriteLine(Key + " " + Dictionary.Item(Key));
    End For;
    // Clear dictionary
    Dictionary.Clear;
End Sub UserProc;

After executing the example a new data dictionary is created that contains three elements. Then the element with the Key 3 key is removed from the dictionary. The console window displays dictionary size and the list of all keys and values of its elements. After executing all the operations the dictionary is cleared.

See also:

IVZDataDictionary