DenSter wrote:
It doesn't work in a situation where you want to copy an array of 8 elements into an array of 12, and he's going to have to find an alternative.
Here's the syntax for COPYARRAY:
COPYARRAY(NewArray, Array, Position [, Length])
The last parameters is Length. If you have a 10 element array, and you want to copy 5 of its elements into a 5 element array, you specify length as 5, just like the example that specified Position=6 and Length=5 to copy into a 5 element array. At that moment, your target as well as your source are both 5 elements, and COPYARRAY will work. It doesn't look at the actual source array, but at the 5 elements you're providing.
Apparently the command doesn't like it when your source array has fewer elements than the target array, it just needs identical numbers of elements. It wants you to provide as many elements as the target array.
It works exactly the way that I expect it to work, and the message is crystal clear to me. It means that if you want to copy x elements into an array that has more than x elements, you're going to have to loop through the elements in C/AL code and assign them that way.
yes, the strange thing of the function is the fact that you can't copy 3 elements in a array with max 5 elements...THIS is the thing that confused me.
about the error: you have two array of 5 elements, then you fill only the first 4 of the first array.
then you use the copyarray function to move the elements to the 2nd array and BANG!error...
the first thing I think is to take a look to array dimensions, which are the same...after that...what I have to do if i follow the error as is?