Add(Value: String): Integer;
Add(Value: string): integer;
Value. Value of new array element.
The Add method adds a new element to array.
To add a new element to array by the specified index, use the IVZStringArray.InsertAt method.
Add a link to the Visualizators system assembly.
Sub UserProc;
Var
Array: IVZStringArray;
i: Integer;
Begin
// Create new array and add elements to it
Array := New VZStringArray.Create;
Array.Add("Value 1");
Array.Add("Value 2");
Array.Add("Value 3");
// Remove element from position with index 1
Array.Remove(1);
// Insert new element to position with index 1
Array.InsertAt(1, "New value");
// Display element value in position with index 1
Debug.WriteLine("Element in position with index 1: " + Array.Item(1));
// Output all array elements
Debug.WriteLine("New array:");
For i := 0 To Array.Count - 1 Do
Debug.WriteLine(Array.Item(i));
End For;
// Output array size
Debug.WriteLine("Array size: " + Array.Count.ToString);
// Clear array
Array.Clear;
End Sub UserProc;
After executing the example an array of string variables is created. The console window displays value of array element with the 1 index, the list of all array elements and array size. Then the array is cleared.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Visualizators;
…
Public Shared Sub Main(Params: StartParams);
Var
Array: IVZStringArray;
i: Integer;
Begin
// Create new array and add elements to it
Array := New VZStringArray.Create();
Array.Add("Value 1");
Array.Add("Value 2");
Array.Add("Value 3");
// Remove element from position with index 1
//Array.Remove(1);
// Insert new element to position with index 1
Array.InsertAt(1, "New value");
// Display element value in position with index 1
System.Diagnostics.Debug.WriteLine("Element in position with index 1: " + Array.Item[1]);
// Output all array elements
System.Diagnostics.Debug.WriteLine("New array:");
For i := 0 To Array.Count - 1 Do
System.Diagnostics.Debug.WriteLine(Array.Item[i]);
End For;
// Output array size
System.Diagnostics.Debug.WriteLine("Array size after clearing: " + Array.Count.ToString());
// Clear array
Array.Clear();
End Sub;
See also: