acopy( ) 函式

acopy( ) 函式

acopy( ) 函式

把一個數組的元素複製到另一個數組中。

基本介紹

  • 中文名:acopy( ) 函式
  • 所屬學科:計算機
  • 所屬分類:計算機函式
語法,參數,說明,函式示例,

語法

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

參數

SourceArrayName, DestinationArrayName
將源數組 SourceArrayName 中的元素一對一地複製到目標數組 DestinationArrayName
中去,源數組中的元素將替換目標數組的元素。
數組可以是一維或二維數組。如目標數組不存在,Visual FoxPro 將自動創建目標數組。這時,目標數組的大小與源數組大小相同。
注意
可以用兩種方法引用二維記憶體變數數組的元素.第一種是用兩個下標值指定元素在數組中的行和列,另一種則指定單個元素的編號。此函式和其他操作二維數組的函式需要單個元素編號(此處為 nFirstSourceElement 和 nFirstDestElement)。使用 AELEMENT( ) 函式,可以根據元素的行和列下標,返回二維數組中某元素的正確元素編號。
nFirstSourceElement
指定源數組中第一個被複製元素的編號,複製從此元素開始(複製時,包含編號為 nFirstSourceElement
的元素)。如果複製時不使用元素編號 nFirstSourceElement,則從源數組的第一個元素開始複製。
nNumberElements
指定複製的源數組的元素數目。如果 nNumberElement 為 -1,則從元素 nFirstSourceElement 開始,複製源數組中所有的元素。
nFirstDestElement
指定目標數組中第一個被替換的元素。

說明

acopy( ) 函式返回複製到目標數組中的元素個數。

函式示例

下面的示例根據 customer 表中選定的記錄創建一個數組,然後用 acopy() 函式創建一個新的數組。
close databases
open database (home( ) + 'samples\data\testdata')
use customer && 打開 customer 表
select distinct company ;
from customer ;
order by company ;
where country = 'germany';
into array gacompanies
= acopy(gacompanies, gacompaniestemp) && 對數組進行複製
clear
display memory like gacompaniestemp

相關詞條

熱門詞條

聯絡我們