Reputation: 805
I have an array which holds a record from a CSV file. Can I for example use the move statement to move elements 5 to 10 out into working storage? Something like: MOVE ExampleArray(5:10) TO WS-TEST. I have been told this is possible instead of having to loop through the array. But I can not seem to get it to compile this way.
Upvotes: 0
Views: 6334
Reputation: 4263
The syntax you are using is called Reference Modification. It is the equivalent of substring() in other languages. Your example code would try to move 10 bytes from ExampleArray+5.
There is a "ALL" subscript concept that is supported. It has limitations, but it MIGHT do what you want. Try something like:
Move ExampleArray(ALL) to WS-Test
Depending upon your compiler, it MIGHT work. I think the spec limits its use to integer functions, but not all compilers do.
Seriously though, perform loops are very simple and easy, just code this:
Perform varying II from 1 by 1
until II > (Length of ExampleArray-Area / Length of ExampleArray(1))
Move ExampleArray(II) to WS-Test(II)
End-Perform
Upvotes: 1