Dimensioned Array Assignment

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
gsherry1
Charter Member
Charter Member
Posts: 173
Joined: Fri Jun 17, 2005 8:31 am
Location: Canada

Dimensioned Array Assignment

Post 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.
gsherry1
Charter Member
Charter Member
Posts: 173
Joined: Fri Jun 17, 2005 8:31 am
Location: Canada

Post 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, ','
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply