leave/exit a 'for each' loop

whwar9739

Member
I have the following scenario:

I have a main table that connects to a secondary table with several fields with 10 extents each.
I would like to go code the following:

Code:
main-blk:
for each tMain:
   sec-blk:
   for each tSec:
      do l-idx = 1 to 10:
         if [I]some criteria[/I]
         then do:
            [I]something.[/I]
            leave sec-blk.
         end. /* if some criteria */
      end. /* do l-idx */
      display [I]xxxxx[/I].
   end. /* for each tSec */
end. /* for each tMain */

Only problem is, i have something almost exactly as it is above but it is not kicking out of the second for-each loop.

Any help is appreciated

Also using AIX and Progress 10.2b.
 

TomBascom

Curmudgeon
How would you know if it is falling out or not?

You would need something like this to tell:

Code:
main-blk:
for each tMain:

   flag = no.

   sec-blk:
   for each tSec:
      do l-idx = 1 to 10:
         if some criteria
         then do:
            something.

            flag = yes.

            leave sec-blk.
         end. /* if some criteria */
      end. /* do l-idx */
      display xxxxx.
   end. /* for each tSec */
 
  message "dropped out?" flag.

end. /* for each tMain */
 
Top