Exit from Loop

Dear all,

As i am a beginner ,i don’t know how to skip one iteration in Loop and continue the next iteration part? Also i need to exit from my loop based on some calculated conditions…How can i do this? I need to write this code inside a Report. I tried the 'exit ’ keyword but it stopped that session itself not the LOOP.Please help me.

Thanks & regards

Jaya

I’m guessing you’re doing a WHILE loop or something. You can just create a new boolean variable called Complete. Set it to false.

WHILE (Original Condition Code) AND (NOT Complete) DO BEGIN

IF Exit Condition THEN

Complete := TRUE;

END;

EXIT takes you out of the current trigger completely

You can also use:

REPEAT
IF SomeCondition THEN
ControlVariable = ‘the value’;
UNTIL ControlVariable = ‘the value’;

It all depends on whether you want the code to execute before or after checking the condition.

Thanks a lot [:D]. But i need to continue the next iteration after skipping this.Is there any skip or break for this purpose??

Please help. I need it urgently

Thanks & Regards

Rose[:)]

You have been given two solutions to your problem. BEFORE you ask for another solution, explain why the first two do not work for you.

There is no keyword to skip one iteration of a loop. You’ll have to figure out a different way to only execute the code in the loop if some condition is true. Hey that sounded like a hint didn’t it [Y]

Mr. Rose

You can try skip function.

ie. CurrReport.skip;

Hi ,Thanks a lot.

I am not using this code inside the Report. But i want it inside a codeunit.

I already used the Condition to exit from the loop

Thanks & regards

Rose

REPEAT

IF NOT (SkipCondition) THEN BEGIN //Whatever reason you want to skip

//Process

END;

IF (ExitTest) THEN EDIT: //Test your condition to completely leave the loop

ExitCondition := TRUE;

UNTIL (ExitCondition)

You can use a while, repeat, whichever… but you need to encase the code you want to execute one way or another and not execute it based off of a condition.

Thanks a lot Kevin[:D]. I will try it

Thanks & Regards

Rose[:)]