nested loops

I have a question. I have a piece of code where there are nested processing loops. say loop 3 is in loop 2 and loop2 is in loop1. I have a condition in loop 3 and if the condition is true code execute the rest of the process in loop 3 if the condition fails the control of the execution must come out of Loop1(which means the control comes out of loop 3 and loop2 and loop 1 at once).
Is there any GOTO statements in Natural to achieve the above scenario. I am new to the natural and adabas.

Thank You and regards
Krishna Prasad

Hi Krishna Prasad,
I think you would need ESCAPE BOTTOM (theres also ESCAPE TOP) statement; unfortunately (or rather fortunately), theres no GOTO in NATURAL nowadays.
Perhaps, the following code might help you (just try it out to understand ESCAPE statement):

DEFINE DATA LOCAL
1 #I (I4)
1 #J (I4)
1 #K (I4)
END-DEFINE
LOOP-ONE-MAIN.
FOR #I = 1 TO 100
LOOP-SEC.
FOR #J=1 TO 50
LOOP-THIRD.
FOR #K = 1 TO 10
DISPLAY ‘=’ #K
IF #K = 5
ESCAPE BOTTOM (LOOP-ONE-MAIN.)
END-IF
END-FOR
END-FOR
END-FOR
WRITE ‘=’ #I ‘=’ #J ‘=’ #K
END

Best regards and good luck.

A few things to add to Nikolay’s response, which should solve your immediate problem.

ESCAPE is a very powerful statement. You should look at the differences between ESCAPE TOP and BOTTOM. While you can ESCAPE BOTTOM with a line reference or a symbolic reference, you cannot do this with ESCAPE TOP. You can only do this to an innermost loop.

Also, if you are working with data loops (e.g. READ, FIND) and have AT BREAK or AT END clauses, be careful about the difference between ESCAPE BOTTOM and ESCAPE BOTTOM IMMEDIATE. Also, look at the relatively new option REPOSITION.

Read up on ESCAPE ROUTINE and ESCAPE MODULE.

Thanks Nikolay and Steve for your response. The information really helps.