Is there a way to "break" out of a loop in a form? The only way that seems to work is EXIT, but I do not want to EXIT because I still want to run the rest of the code for other cases. BREAK/SKIP/QUIT do not work either. They seem to only work on reports, i.e. CurrReport.BREAK;
What is the BREAK version for forms? Something that works like CurrReport.BREAK but in forms.
0
Comments
You can use a Boolean value to control a loop in code.
Example
MyBool := FALSE;
REPEAT
Your Code Here
Set MyBool = TRUE when condition met.
UNTIL (NEXT = 0) OR MyBool
IF PromoDet2.FINDSET THEN
REPEAT
CASE PromoDet2."Sales Type" OF
PromoDet2."Sales Type"::Item :
BEGIN
IF SalesLine2.INSERT THEN
CurrForm.CLOSE;
EXIT; // I want to replace this exit with someting similar to break
END;
PromoDet2."Sales Type"::"Product Group" :
BEGIN
//code here
END;
PromoDet2."Sales Type"::"Shipping Agent Service":
BEGIN
//code here
END;
END;
UNTIL PromoDet2.NEXT = 0;
Instead of using EXIT, I want to use something similar to BREAK, so that the rest of the code in other cases can still be run. This code is done on a form, so I cannot do things like CurrReport.BREAK.
My question is that how do you break out of that IF statement above without using EXIT?
Where are you putting your code?
This is someting you might use on a OnValidate Trigger
PS Don't forget about your
If..Then..Else's or Then Begin..Else Begin..too
They can be very useful
http://www.BiloBeauty.com
http://www.autismspeaks.org
RIS Plus, LLC
1) not know what you are trying to do
2) looking at your code I just looked quick and saw you wanted to use case but how could a "shipping agent service" or "product group" be a sales type?
you might be just setting this up all wrong - that's why we need to know what you are trying to accomplish
http://www.BiloBeauty.com
http://www.autismspeaks.org
So there is no keyword to exit a loop in C/AL, but you CAN make the loop stop if a condition is met, by including that condition in the UNTIL part.
RIS Plus, LLC
http://www.BiloBeauty.com
http://www.autismspeaks.org