Page 1 of 1

Dimensioned Array Assignment

Posted: Wed Oct 12, 2005 10:05 am
by gsherry1
Could somebody please post example of how to assign multiple array elements in one statement. Something similar to C array initialization list.

I can find commands for assigning all elements the same value, and building a array from file contents, but how about hard coding a static table.

ie. I want to do something like this:

DIM myArray(3,3) = {{1,2,3},{4,5,6},{7,8,9}}

Are such assignments possible in DS Basic?

Thanks in advance.

Posted: Wed Oct 12, 2005 11:07 am
by gsherry1
I think I solved my own problem. I used the MATPARSE functionality.

DIM myArray(40,3)
valStr=<120 array values comma delimited>
MATPARSE myArray FROM valStr, ','

Posted: Wed Oct 12, 2005 3:08 pm
by ray.wurlod
The only alternative is MAT, but this must assign the same value to every element, for example

Code: Select all

MAT myArray = 0
Otherwise you have discovered the correct answer. Well done.