Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 14:51 16 Nov 2025 Privacy Policy
Jump to

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.

Forum Index : Microcontroller and PC projects : Multidimensional Arrays

Author Message
PilotPirx

Senior Member

Joined: 03/11/2020
Location: Germany
Posts: 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 Kingdom
Posts: 10588
Posted: 08:00pm 20 Nov 2020
Copy link to clipboard 
Print this post

  Quote  DIM array1%(1,2)=(1,2,3,4,5,6)     'works, but wrong sequence


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.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025