Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
PilotPirx Senior Member Joined: 03/11/2020 Location: GermanyPosts: 105
Posted: 07:54pm 20 Nov 2020
Copy link to clipboard
Print this post
Hi,
I'm a cmm2 beginner and I have a question about multidimensional arrays.
How can I specify the content of a two-dimensional array, for example?
DIM array1%(1,2)=((1,2,3),(4,5,6)) 'gives an error
DIM array1%(1,2)=(1,2,3,4,5,6) 'works, but wrong sequence
array%(0,0) is 1 array%(1,0) is 2
'How to fill
DIM row%=1 DIM column%=2
dim array%(row%,column%)=(1,2,3, 'row 1 4,5,6) 'row 2
This gives an Error too. In the past, i programmed with C. This was easier to declare. I found no examples for CMM2 basic.
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10588
Posted: 08:00pm 20 Nov 2020
Copy link to clipboard
Print this post
Depends what you mean by wrong. The storage of arrays in MMBasic in memory is with the first index moving fastest, then the second, etc. So just re-order your values to match.