Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm using 2 nested loops.
In the inner loop, I'm using IF blocks.
I would like to define a condition which would force the Next of the inner loop.
Using the Exit would cause performing commands in vetween the loops,
which is not desired.
I bypass it by using flags.But I wish to know whether it is possible to define something like:
IF condition THEN
NEXT
ENDIF
To this end, didn't find a similar syntax.
Thanks 🙂
Hi,
Try this, if you don't give next it will automatically goto next for because u r else below it. Remove next.
FOR I = 1 to $(vDelivNoOfRows)
// Here come a few commands
FOR j = $(Counter)+1 to (vReceiveNoOfRows)
//--Some commands
IF vBalance < 0 then
LET VDelQty = fabs($(vBalance));
SET vNextDelDoc = 'F';
LET Counter = $(Counter) + 1;
ELSEIF vBalance = 0 then
LET Counter = $(Counter) + 1;
SET vNextDelDoc = 'T';
ELSE
LET VRecvQty = vBalance;
SET vNextDelDoc = 'T';
EXIT For;
ENDIF;
NEXT;
NEXT;
Regards,
Jagards.
can you load your script please?
Hi Manish,
It looks something like that. The NEXT in red causes a script error:
FOR I = 1 to $(vDelivNoOfRows)
// Here come a few commands
FOR j = $(Counter)+1 to $(vReceiveNoOfRows)
//--Some commands
IF vBalance < 0 then
LET VDelQty = fabs($(vBalance));
SET vNextDelDoc = 'F';
LET Counter = $(Counter) + 1;
NEXT;
ELSEIF vBalance = 0 then
LET Counter = $(Counter) + 1;
SET vNextDelDoc = 'T';
ELSE
LET VRecvQty = vBalance;
SET vNextDelDoc = 'T';
EXIT For;
ENDIF;
NEXT;
NEXT;
Thanks!
May be this?
FOR I = 1 to $(vDelivNoOfRows)
// Here come a few commands
FOR j = $(Counter)+1 to $(vReceiveNoOfRows)
//--Some commands
IF vBalance < 0 then
LET VDelQty = fabs($(vBalance));
SET vNextDelDoc = 'F';
LET Counter = $(Counter) + 1;
NEXT;
ELSEIF vBalance = 0 then
LET Counter = $(Counter) + 1;
SET vNextDelDoc = 'T';
ELSE
LET VRecvQty = vBalance;
SET vNextDelDoc = 'T';
EXIT For;
ENDIF;
END IF;
NEXT;
NEXT;
Hi,
Sometimes, you want to move directly to the next record in the inner loop,
bypassing a group of commends between the two NEXT commands.
If it is not enabled in QlikView, the only way to do it is by using EXIT FOR and flags.
Thanks!
Hi,
Try this, if you don't give next it will automatically goto next for because u r else below it. Remove next.
FOR I = 1 to $(vDelivNoOfRows)
// Here come a few commands
FOR j = $(Counter)+1 to (vReceiveNoOfRows)
//--Some commands
IF vBalance < 0 then
LET VDelQty = fabs($(vBalance));
SET vNextDelDoc = 'F';
LET Counter = $(Counter) + 1;
ELSEIF vBalance = 0 then
LET Counter = $(Counter) + 1;
SET vNextDelDoc = 'T';
ELSE
LET VRecvQty = vBalance;
SET vNextDelDoc = 'T';
EXIT For;
ENDIF;
NEXT;
NEXT;
Regards,
Jagards.
Do you have any syntactical example from any other language to understand it better? I guess what you want can be achieved using IF..Else properly. Like:
For a=1 to 10
If a<>2 then // for a=2, the loop would move to next
...all others IFs.
End If
Next a
Hi,
Try Exit For When|Unless.
Regards,
Jagan.
Got It!
Thanks!
Well, I thought I recalled that it's possible in VB.
But It's not.
The right way to do it is like you and Jagan suggested.
Thanks!