For-Loop PeopleCode Array

2.2k views Asked by At

Is it possible to loop for two array statements? I am trying to put it on display just to see if I will be getting the correct values, but it turned out it that my code is only working for single statement:

Here's the code (not working):

&DelFrom = CreateArray();
&DelTo = CreateArray();


For &del_from = 1 To &DelFrom.Len
And &del_to = 1 To &DelTo.Len

Warning MsgGet (0, 0, &DelFrom [&del_from] "-" &DelTo [&del_to]);

End-For;

Here's the other one (working, but for only the del_from for example):

For &del_from = 1 To &DelFrom.Len

Warning MsgGet (0, 0, &DelFrom [&del_from]);

End-For;
1

There are 1 answers

1
Ben Rubin On BEST ANSWER

You can't loop on two different iterators within the same for loop, but you can nest loops.

For &del_from = 1 To &DelFrom.Len
   For &del_to = 1 To &DelTo.Len
      Warning MsgGet (0, 0, &DelFrom [&del_from] "-" &DelTo [&del_to]);
   End-For;
End-For; 

This will get you every permutation of values from &DelFrom and &DelTo within you loop body. Is that what you're trying to accomplish?