Friday, May 21, 2004

Insert a column into an array:

dimension myarray[2,3]
myarray[1,1]="R1C1"
myarray[1,2]="R1C2"
myarray[1,3]="R1C3"
myarray[2,1]="R2C1"
myarray[2,2]="R2C2"
myarray[2,3]="R2C3"


=addcol(@myarray)
CLEAR
DISPLAY MEMORY LIKE myarray


FUNCTION addcol
PARAMETERS aArray
LOCAL nRows,nCols
nRows=ALEN(aArray,1)
nCols=ALEN(aArray,2)
DIMENSION aArray[nRows*(nCols+1)]

FOR i=(nCols+1) TO nRows*(nCols+1) STEP (nCols+1)
AINS(aArray,i)
NEXT
DIMENSION aArray[nRows,nCols+1]
return
ENDFUNC

Thanks to Peter Cushing via ProFox@leafe.com

No comments: