Array.value Method [AX 2012]
Gets or sets the value of the array element that is stored at the specified index.
The return type is the same as the type of the array.
If an attempt is made to read a value at an index that is beyond the last index that has a value, an exception is thrown.
If a value is written to a nonexistent location, all locations between the previous element and the nonexistent location are filled with default values, and the array is expanded.
The following example creates an array of integers and then uses the value method to add some values to the array. It then uses the value method to get the values that are stored in the array and test them.
{
int i;
// Create an integer array
Array ia = new Array (Types::Integer);
// Write some elements in it
for (i = 1; i< 10; i++)
{
ia.value(i, i*2);
}
// Check the values
for (i = 1; i< 10; i++)
{
if (ia.value(i) != 2*i)
{
print "Error!";
}
}
pause;
}
Community Additions
ADD
Show: