Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Combining Multidimensional Arrays
#1
Hi All,
I know this could theoretically be very complicated but my case example is simple...basically replicating the "from" str function. I have two 2-dimensional str arrays and I just want to combine them into 1 array, maintaining dimensions etc. I realize I could read one out into the other with a "for i 0...." type statement, but it gets hairy in that the counter integer for the two different arrays will be different reading into the third (combined)..... I know I could figure it out eventually but I thought I would check if there was an easier way.
Thanks, Stuart
#2
Macro Macro1307
Code:
Copy      Help
out

;this code is just to create 2 2-dim arrays
ExcelSheet es1.Init("Sheet1")
ExcelSheet es2.Init("Sheet2")
ARRAY(str) a1 a2 a3
int i
es1.GetCells(a1)
es2.GetCells(a2)
;out "%i %i" a1.len(1) a1.len(2)
;out "%i %i" a2.len(1) a2.len(2)
;____________________________

;combine: a3 = a1 + a2
;assuming that a1 and a2 have same number of columns and rows
a3.create(a1.len(1) a1.len(2))
int r c
for r 0 a1.len(2)
,for c 0 a1.len(1)
,,a3[c r].from(a1[c r] a2[c r])
;_____________________________

;results
for r 0 a3.len(2)
,out "---- row %i ----" r
,for c 0 a3.len(1)
,,out a3[c r]


Forum Jump:


Users browsing this thread: 1 Guest(s)