IVZItemsNames.Add

Fore Syntax

Add(Key: String, Value: String);

Fore.NET Syntax

Add(Key: string, Value: string);

Parameters

Key. Element key in collection.

Value. Value of element in collection.

Description

The Add method adds a new element into the collection.

Comments

To remove an element from collection by its key, use the IVZItemsNames.Remove method.

Fore Example

To execute the example, add a link to the Visualizators system assembly.

Sub UserProc;
Var
    Names: IVZItemsNames;
    Item: String;
    Key: Variant;
Begin
    Names := New VZItemsNames.Create;
    Names.Add("14""Belgorodskaya oblast");
    Names.Add("15""Bryanskaya oblast");
    Names.Add("17""Vladimirskaya oblast");
    Debug.WriteLine("Original amount of elements in collection: " + 
        Names.Count.ToString);
    // Get first collection element
    
Key := Names.AllKeys.Item(0);
    Item := Names.Item(Key);
   Debug.WriteLine("First element" + Key + " " + Item);
    // Remove this element
    Names.Remove(Key);
    Debug.WriteLine("Collection size after element is removed «" + Item + "»: " + 
        Names.Count.ToString);
    // Clear entire collection
    Names.Clear;
End Sub UserProc;

After executing the example a collection of three elements is created. Then one of the elements is removed form the collection. The console window displays collection size after its creation and after one element removal:

Original amount of collection elements: 3

Collection size after the "Belgorodskaya oblast" element is removed: 2

After executing all the operation the collection is cleared.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Public Shared Sub Main(Params: StartParams);
Var
    Names: IVZItemsNames;
    Item: String;
    Key: Object;
Begin
    Names := New VZItemsNames();
    Names.Add("14""Belgorodskaya oblast");
    Names.Add("15""Bryanskaya oblast");
    Names.Add("17""Vladimirskaya oblast");
    System.Diagnostics.Debug.WriteLine("Original amount of elements in collection: " + 
        Names.Count.ToString());
    // Get first element of names collection
    
Key := Names.AllKeys.Item[0];
    Item := Names.Item[Key];
   System.Diagnostics.Debug.WriteLine("First element: " + Key + " " + Item);
    // Remove this element
    Names.Remove(Key);
    System.Diagnostics.Debug.WriteLine("Collection size after element is removed "" + 
        Item + "»: " + Names.Count.ToString());
    // Clear entire collection
    Names.Clear();
End Sub;

See also:

IVZItemsNames