← 都来码 / Dolaima← 例程索引dbase/school/arrays.prg 原文

dbase/school/arrays.prg · 1065 字节 · 下载原文

// Declare and initialize two-dimensional array
   Local arr1 := { { "NITEM","N",10,0 }, { "CONTENT","C",60,0} }
   // Create an empty array
   Local arr2 := {}
   // Declare three-dimensional array
   Local arr3[2,100,3]
   // Create an array
   Local arr4 := Array(50)

   // Array can be dynamically resized:
   arr4 := ASize( arr4, 80 )

// Adding new item to array, its size is incremented
   Aadd( arr1, { "LBASE","L",1,0 } )
// Delete the first item of arr3, The size of arr3 remains the same,   all items are shifted to one position, the last item is replaced by Nil:
   ADel( arr1, 1 )
// Assigning a value to array item
   arr3[1,1,1] := 11.4

x := arr3[1,10,2]
// The retrieved item can be nested array, in this case it isn't copied, the pointer to it is assigned

// Fill the 20 items of array with 0, starting from 5-th item:
   AFill( arr4, 0, 5, 20 )
//Copy 10 items from arr4 to arr3[2], starting from the first position:
   ACopy( arr4, arr3[2], 1, 10 )
//Duplicate the whole or nested array:
   arr5 := AClone( arr1 )
   arr6 := AClone( arr1[3] )