次の方法で共有


ACOPY( ) Function

Copies elements from one array to another array.

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

Return Values

Numeric

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. If the destination array already exists, it is redimensioned to the size 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.

Remarks

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

Example

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

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

ADEL( ) Function | AELEMENT( ) Function | AINS( ) | ASCAN( ) Function | ASORT( ) Function | DIMENSION Command