- Copying arrays of different dimensions
- Various
ArrayCopy (Function) In french: TableauCopie
MyArray is array of 2 strings MyArray[1] = "WINDEV" MyArray[2] = "WEBDEV" MyArrayCopy is array of 2 strings ArrayCopy(MyArray, MyCopiedArray)
Versions 18 and later
arrA1 is array of int = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] // Copy the first 3 elements from arrA1 to arrA2 arrA2 is array of int ArrayCopy(arrA1, arrA2, 1, 3) // [1, 2, 3] // Copy 4 integers from position 4 arrA3 is array of int ArrayCopy(arrA1, arrA3, 4, 4) // [4, 5, 6, 7] // Copy the end of array from position 6 arrA4 is array of int ArrayCopy(arrA1, arrA4, 6) // [7, 8, 9, 10]
New in version 18
arrA1 is array of int = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] // Copy the first 3 elements from arrA1 to arrA2 arrA2 is array of int ArrayCopy(arrA1, arrA2, 1, 3) // [1, 2, 3] // Copy 4 integers from position 4 arrA3 is array of int ArrayCopy(arrA1, arrA3, 4, 4) // [4, 5, 6, 7] // Copy the end of array from position 6 arrA4 is array of int ArrayCopy(arrA1, arrA4, 6) // [7, 8, 9, 10]
arrA1 is array of int = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] // Copy the first 3 elements from arrA1 to arrA2 arrA2 is array of int ArrayCopy(arrA1, arrA2, 1, 3) // [1, 2, 3] // Copy 4 integers from position 4 arrA3 is array of int ArrayCopy(arrA1, arrA3, 4, 4) // [4, 5, 6, 7] // Copy the end of array from position 6 arrA4 is array of int ArrayCopy(arrA1, arrA4, 6) // [7, 8, 9, 10]
Syntax
ArrayCopy(<Source array> , <Destination array> [, <Start position of copy> [, <Size of copy>]])
<Source array>: Array Name of the Array variable to copy. <Destination array>: Array Name of the Array variable into which the copy must be performed. <Start position of copy>: Optional integer Versions 18 and laterSubscript in the source array from which the copy must be performed. This subscript must be included between 1 and the last array subcript. This parameter is set to 1 by default. Otherwise, a WLanguage error occurs at run time. This parameter cannot be used with an associative array.
New in version 18Subscript in the source array from which the copy must be performed. This subscript must be included between 1 and the last array subcript. This parameter is set to 1 by default. Otherwise, a WLanguage error occurs at run time. This parameter cannot be used with an associative array.
Subscript in the source array from which the copy must be performed. This subscript must be included between 1 and the last array subcript. This parameter is set to 1 by default. Otherwise, a WLanguage error occurs at run time. This parameter cannot be used with an associative array.
<Size of copy>: Optional integer Versions 18 and laterSize of copy. Caution: The interval of values defined by <Start position of copy> and <Size of copy> must be entirely included in the source array. Otherwise, a WLanguage error occurs at run time. By default, the copy is performed from the specified subscript to the end of the array. This parameter cannot be used with an associative array.
New in version 18Size of copy. Caution: The interval of values defined by <Start position of copy> and <Size of copy> must be entirely included in the source array. Otherwise, a WLanguage error occurs at run time. By default, the copy is performed from the specified subscript to the end of the array. This parameter cannot be used with an associative array.
Size of copy. Caution: The interval of values defined by <Start position of copy> and <Size of copy> must be entirely included in the source array. Otherwise, a WLanguage error occurs at run time. By default, the copy is performed from the specified subscript to the end of the array. This parameter cannot be used with an associative array.
Remarks Copying arrays of different dimensions - Simple array: A WLanguage error occurs at run time.
- Dynamic array: The destination array is entirely re-created (and therefore cleared) with the copy.
Various - A WLanguage error occurs if the type of the elements found in the destination array differs from the type of the elements found the source array.
- If the destination array contains elements, these elements are deleted.
- This function can be used with associative arrays. In this case, it is only possible to copy the entire array. It is not possible to copy part of the associative array.
- This function cannot be used with the fixed arrays.
This page is also available for…
|
|
|
| |
| Check the results of the examples |
|
| arrA1 is array of int = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] // Copy the first 3 elements from arrA1 to arrA2 arrA2 is array of int ArrayCopy(arrA1, arrA2, 1, 3) // [1, 2, 3] // Copy 4 integers from position 4 arrA3 is array of int ArrayCopy(arrA1, arrA3, 4, 4) // [4,5, 6, 7] // Copy the end of array from position 6 arrA4 is array of int ArrayCopy(arrA1, arrA4, 6) // [6, 7, 8, 9, 10] |
|
|
|
| |
| |
| |
| |
| |
| |
| | |
|