0

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;
capacitive
  • 17
  • 6
  • Never used peoplesoft or peoplecode--in fact, just learnt about it from your post. In modern imperative languages, it's generally possible to nest one 'for' loop within another. Have you thought about doing that? – Mark Fernandes Dec 18 '20 at 10:55
  • Yes, however we just have to use only peoplecode on this project. – capacitive Dec 20 '20 at 07:05

1 Answers1

1

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?

Ben Rubin
  • 6,909
  • 7
  • 35
  • 82