Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
create (declare) resizable multidimensional Array
#1
I have this code which works but where the array grid is fixed to [1 4]

Macro Macro10
Code:
Copy      Help
str ss=
;app_1
;app_2
;app_3
;app_4


ARRAY(str) grid.create(1 4)
int i

for i 0 numlines(ss)
,_s.getl(ss i)
,grid[0 i]=_s

ICsv- t_csv=CreateCsv()
t_csv.FromArray(grid)


Is it possible to declare "grid" in a resizable way?

I read this topic:
Help with multidimensional arrays

And based on this:

Macro Macro10
Code:
Copy      Help
ARRAY(str) a.create(6 0) ;;first dimension has 6 elements, one for each word; second dimension is resizable. Imagine that first dimension is horizontal (x), second vertical (y).

I assumed when declaring the second index as zero it would make the second index resizable
But this does not work (making bot dimensions resizable)
Code:
Copy      Help
ARRAY(str) grid.create(0 0)

This also doesn't work (making second dimension resizable)

Code:
Copy      Help
ARRAY(str) grid.create(1 0)

Only when declaring the array "grid" in a fixed way makes it work correctly.
#2
Macro Macro1841
Code:
Copy      Help
str ss=
;app_1
;app_2
;app_3
;app_4


ARRAY(str) grid.create(1 0)
int i

foreach _s ss
,grid[0 grid.redim(-1)]=_s

for i 0 grid.len
,out grid[0 i]
Can resize only the rightmost dimension.
#3
OK!
THANK YOU!!!


Forum Jump:


Users browsing this thread: 1 Guest(s)