#DefineFunction udfArrayCopy (arrArray) arrE = ArrDimension (6) For intD = 0 To 5 arrE [intD] = ArrInfo (arrArray, intD) Next arrNew = ArrDimension (arrE [1], arrE [2], arrE [3], arrE [4], arrE [5]) For intD = 1 To arrE [0] arrE [intD] = arrE [intD] - 1 Next Switch arrE [0] Case 1 For intA = 0 To arrE [1] arrNew [intA] = arrArray [intA] Next Break Case 2 For intA = 0 To arrE [1] For intB = 0 To arrE [2] arrNew [intA, intB] = arrArray [intA, intB] Next Next Break Case 3 For intA = 0 To arrE [1] For intB = 0 To arrE [2] For intC = 0 To arrE [3] arrNew [intA, intB, intC] = arrArray [intA, intB, intC] Next Next Next Break Case 4 For intA = 0 To arrE [1] For intB = 0 To arrE [2] For intC = 0 To arrE [3] For intD = 0 To arrE [4] arrNew [intA, intB, intC, intD] = arrArray [intA, intB, intC, intD] Next Next Next Next Break Case 5 For intA = 0 To arrE [1] For intB = 0 To arrE [2] For intC = 0 To arrE [3] For intD = 0 To arrE [4] For intE = 0 To arrE [5] arrNew [intA, intB, intC, intD, intE] = arrArray [intA, intB, intC, intD, intE] Next Next Next Next Next Break EndSwitch Return arrNew ;.......................................................................................................................................... ; This UDF "udfArrayCopy" creates a new array from a given array with structure and contents identical. ; ; First published by George Vagenas in Spring 2001? ; Modified by Detlev Dalitz.20020203.20090507.20090519. ;.......................................................................................................................................... #EndFunction ; Test. :Test1 arrA = Arrayize ("one,two,three,four", ",") ; Create a 1-dim array with 4 elements. intElements_A = ArrInfo (arrA, 6) ; 4. arrB = udfArrayCopy (arrA) ; Create new array B from array A. intElements_B = ArrInfo (arrB, 6) ; 4. DropWild ("int*") DropWild ("arr*") :Test2 arrA = ArrDimension (2, 4, 6, 5, 3) ; Create a 5-dim array with 2*4*6*5*3 = 720 elements. ArrInitialize (arrA, "Test") ; Set all elements to a value. intElements_A = ArrInfo (arrA, 6) ; 720. arrB = udfArrayCopy (arrA) ; Create new array B from array A. intElements_B = ArrInfo (arrB, 6) ; 720. DropWild ("int*") DropWild ("arr*") Exit