JavaScript Editor js editor     Web development 



Main Page

Copies elements from one array to another array.

ACOPY(SourceArrayName, DestinationArrayName    
[, nFirstSourceElement [, nNumberElements [, nFirstDestElement ]]])

Parameters

SourceArrayName, DestinationArrayName


Specifies the source array SourceArrayName from which elements are copied one-to-one to the destination array DestinationArrayName. The elements in the source array replace the elements in the destination array. The arrays can be one- or two-dimensional. If the destination array doesn't exist, Visual FoxPro automatically creates it. In such a case, the size of the destination array will be the same as that of the source array.
Note:
You can refer to an element in a two-dimensional variable array in two ways: The first uses two subscripts to specify the row and column position of the element in the array; the other uses a single-element number. This function and others that manipulate two-dimensional arrays require single-element numbers (here, nFirstSourceElement and nFirstDestElement). Use AELEMENT(В ) to return the proper element number for a two-dimensional array from its row and column subscripts.

nFirstSourceElement


Specifies the first element number in the source array to be copied; inclusive (element number nFirstSourceElement is included in the copying). If nFirstSourceElement isn't included, copying begins with the first element in the source array.
nNumberElements


Specifies the number of elements copied from the source array. If nNumberElements is –1, all elements of the source array beginning with element nFirstSourceElement are copied.
nFirstDestElement


Specifies the first element in the destination array to be replaced.

Return Value

Numeric. ACOPY(В ) returns the number of elements copied to the destination array.

Remarks

Copying a member array to an existing non-member array with certain dimensions using the ACOPY(В ) function might generate the error, "Subscript is outside defined range." You can avoid this error changing the dimension of the destination array to a single element before calling ACOPY(В ). For more information, see DIMENSION Command.

Example

The following example creates an array from selected records in the customer table and then uses ACOPY(В ) to create a new array.

В Copy Code
CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'data\testdata')
USE customer     && Open customer table

SELECT DISTINCT company ;
   FROM customer ;
   ORDER BY company ;
   WHERE country = 'Germany';
   INTO ARRAY gaCompanies
= ACOPY(gaCompanies, gaCompaniesTemp)  && Make a copy of the array
CLEAR 
DISPLAY MEMORY LIKE gaCompaniesTemp

See Also



JavaScript Editor js editor     Web development