I need jagged dynamic array in PL/I but I don't know how to realize it. Need something like:
dcl v dim(*,*) fixed bin(31) ctl;
allocate v dim(5,*);
allocate v(1) dim(10);
allocate v(2) dim(100);
How can I do it?
I solved this this problem in a way that piet.t had told. Have created array of pointers and allocate arrays for each pointer. This looks not very convenient IMHO.
mainp:procedure options(main);
dcl n fixed bin(31);
dcl pp ptr;
dcl 1 pointers based(pp),
2 length fixed bin(31),
2 at dim(n refer (length)) ptr;
dcl m fixed bin(31);
dcl 1 values based,
2 length fixed bin(31),
2 at dim(m refer (length)) fixed bin(31);
n=2;
allocate pointers;
m=2;
allocate values set(pointers.at(1));
m=4;
allocate values set(pointers.at(2));
pointers.at(1)->values.at(1)=1;
pointers.at(1)->values.at(2)=2;
pointers.at(2)->values.at(1)=10;
pointers.at(2)->values.at(2)=20;
pointers.at(2)->values.at(3)=30;
pointers.at(2)->values.at(4)=40;
put skip list("Line 1 length: ",pointers.at(1)->values.length);
put skip list("Line 2 lenght: ",pointers.at(2)->values.length);
put skip list('');
put skip list(pointers.at(1)->values.at(1),
pointers.at(1)->values.at(1));
put skip list(pointers.at(2)->values.at(1),
pointers.at(2)->values.at(2),
pointers.at(2)->values.at(3),
pointers.at(2)->values.at(4));
end;