Dear Readers ,
This blog will tell you about new datatypes available in AL language for MS Dynamics 365 business Central.
This blog will tell you about new datatypes available in AL language for MS Dynamics 365 business Central.
Arrays :
Arrays are complex variables that contain a group of variables, with the same data type. An array is declared as a variable with:
- An identifier
- A data type
- Elements
- An index
- A dimension
An array holds multiple values, and these values are stored in the elements of an array. You can access these values by using the index. The index can also be a value stored in another variable. With this you can create a loop where you increment a certain variable, to loop trough every element in an array.
By using the dimension property, you can define how many dimensions your array will hold.
One-dimensional and multi-dimensional array
When creating a variable of the array data type, you must define upfront how many elements you will have in your array. The most used is the one-dimensional array. This is just a list of elements with the same data type.
We can represent an array as a row of values:
To create an array, we can use the following code:
To access an element in an array you will need to use the array element syntax:
In the example above, SaleAmount is our identifier, and we are accessing the fifth element in the array. We are setting the value 0 in the fifth element. This would result in:
Because there is only one element between the square brackets, this indicates that we are using a one-dimensional array. If we want to have a multi-dimensional array, you would use a comma separated list between the brackets.
A multi-dimensional array can be represented as a table of values:
To create an array, we can use the following code:
To create an array, we can use the following code:
To access an element in an array, you will need to use the array element syntax:
In the example above, we are accessing the fifth row and the third column in the array. We are setting the value 0. This would result in:
No comments:
Post a Comment