Add(Value: Variant): Integer;
Add(Value: System.Object): System.Int32;
Value. A new element of data array.
The Add method adds a new element to data array.
The module containing the example should have link to the Visualizators assembly. This procedure should be called from the Main entry point.
Create a new data array and add elements to it. Display array size, insert a new element into the position with index 2 using the InsertAt method and display it, then display array size. Remove the element with index 2 using the Remove method and display array size. Clear array using the Clear method and display its size:
Sub UserProc;
Var
Array: IVZDataArray; // Array
Begin
// Create new array and add elements to it
Array := New VZDataArray.Create;
Array.Add("Item1");
Array.Add("Item2");
Array.Add("Item3");
// Output array size
Debug.WriteLine("Array size: " + Array.Count.ToString);
// Display elements item with index 2
Debug.WriteLine("Array item with index 2: " + Array.Item(2));
// Add new elements into array into position 2
Array.InsertAt(2,"Item4");
Debug.WriteLine("Item added");
// Display array element with index 2
Debug.WriteLine("Array item with index 2: " + Array.Item(2));
// Output array size
Debug.WriteLine("Array size: " + Array.Count.ToString);
// Remove array element
Array.Remove(2);
Debug.WriteLine("Item removed");
// Output array size
Debug.WriteLine("Array size: " + Array.Count.ToString);
// Clear array
Array.Clear;
Debug.WriteLine("Array cleared");
// Output array size
Debug.WriteLine("Array size: " + Array.Count.ToString);
End Sub UserProc;
After executing the example, the development environment console window shows size and type of the created array, the element with index 2 after it was added and removed, and array size after it was cleared:
Array size: 3.
Array item with index 2: Item3.
Item added.
Array item with index 2: Item4.
Array size: 4.
Item removed.
Array size: 3.
Array cleared.
Array size: 0.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Visualizators;
...
Public Shared Sub Main(Params: StartParams);
Var
Array: IVZDataArray; // Array
Type: visualizatorDataArrayType; // Array type
Begin
// Create new array and add elements to it
Array := New VZDataArray.Create();
Array.Add("Item1");
Array.Add("Item2");
Array.Add("Item3");
// Output array size
System.Diagnostics.Debug.WriteLine("Array size: " + Array.Count.ToString());
// Display array element with index 2
System.Diagnostics.Debug.WriteLine("Array item with index 2: " + Array.Item[2]);
// Add new element into array into position 2
Array.InsertAt(2, "Item4");
System.Diagnostics.Debug.WriteLine("Item added");
System.Diagnostics.Debug.WriteLine("Array item with index 2: " + Array.Item[2]);
System.Diagnostics.Debug.WriteLine("Array size: " + Array.Count.ToString());
// Remove array element
Array.Remove(2);
System.Diagnostics.Debug.WriteLine("Item removed");
System.Diagnostics.Debug.WriteLine("Array size: " + Array.Count.ToString());
// Clear array
Array.Clear();
System.Diagnostics.Debug.WriteLine("Array cleared");
System.Diagnostics.Debug.WriteLine("Array size: " + Array.Count.ToString());
End Sub;
See also: