Do you know C/AL "continue" method?

GRUBBYFANSGRUBBYFANS Member Posts: 154
today, I am writing code,I found a question ,
for example:
i integer
for i:=1 to 3 do begin

if i=2 then
continue??here is error


end

so please tell me in C/AL replace "continue" the method,it is like "skip" method
I d'like to skip this circle,not like "break",so give me a idea,thanks

Answers

  • klavinklavin Member Posts: 117
    You are going to be looping in the i := 1 to 3, with each loop its incrementing... I'm not sure if I'm understanding this right, but if you want to ignore two then you can always do:
    IF i <> 2 THEN BEGIN
       //some code here
    END;
    

    and do the part you wanted to do for 1 and 3 within that section.

    SKIP is used to skip a record in fashion of CurrReport.SKIP, or DataPort.SKIP, etc... Since you are doing i := 1 TO 3, its going to go through 1, 2, and 3 no matter what, that's what its being told to do.

    What exactly are you trying to do with it so we can better help and understand it?

    Kevin
    -Lavin
    "Profanity is the one language all programmers know best."
  • GRUBBYFANSGRUBBYFANS Member Posts: 154
    klavin wrote:
    You are going to be looping in the i := 1 to 3, with each loop its incrementing... I'm not sure if I'm understanding this right, but if you want to ignore two then you can always do:
    IF i <> 2 THEN BEGIN
       //some code here
    END;
    

    and do the part you wanted to do for 1 and 3 within that section.

    SKIP is used to skip a record in fashion of CurrReport.SKIP, or DataPort.SKIP, etc... Since you are doing i := 1 TO 3, its going to go through 1, 2, and 3 no matter what, that's what its being told to do.

    What exactly are you trying to do with it so we can better help and understand it?

    Kevin
    ok,I understand you idea,but I 'd like to know like "continue" method,there isn't the method in Navision,please tell me answer,thank you
  • DenSterDenSter Member Posts: 8,305
    You answered your own question:
    GRUBBYFANS wrote:
    there isn't the method in Navision
    There is no such thing as a 'Continue' command in C/AL, but you already knew that.
  • SavatageSavatage Member Posts: 7,142
    Not sure If I'm following but how I read the question you could use a confirm no???

    if 1 then do something
    if 2 then confirm (would you like to go to 3 or would you like to do something else)

    I might be right on or way off :mrgreen:
  • SavatageSavatage Member Posts: 7,142
    Savatage wrote:
    Not sure If I'm following but how I read the question you could use a confirm no???

    if 1 then do something
    if 2 then confirm (would you like to go to 3 or would you like to do something else)

    I might be right on or way off :mrgreen:

    Not sure you explained well because if i = 1 to 3 it will always hit 2 what do you want to skip.

    these vague theoretical hypotheticals give me a headache-ical :lol:
  • DenSterDenSter Member Posts: 8,305
    I should read the original question more carefully :oops: . You could do something like this:
    i := 0; // i is an integer
    ContinueProcessing := TRUE; // ContinueProcessing is a boolean
    REPEAT
      i := i + 1;
      ContinueProcessing := CONFIRM('i equals ' + FORMAT(i) + '. Do you want to continue?',TRUE);;
    UNTIL (i = 10) OR (ContinueProcessing = FALSE);
    
    As long as you hit the Yes button it shold keep looping, and jump out when you click no. Put this code in a button on a test form and see what happens. I haven't tested the code yet so you might need to play around with it a little bit.
Sign In or Register to comment.