C/AL Code

Stan09
Stan09 Member Posts: 63
Hi, all

I search for C/al intructions to break a specific step in "While" loop instruction.
If hou have any idea about it, pease share with me.
Thanks.

Answers

  • lvanvugt
    lvanvugt Member Posts: 774
    Didn't come across BREAK (in case of Dataport, Report or XMLport)?

    In other cases: can't you create a valid condition in the WHILE statement that make the loop end?
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • Stan09
    Stan09 Member Posts: 63
    lvanvugt wrote:
    Didn't come across BREAK (in case of Dataport, Report or XMLport)?

    In other cases: can't you create a valid condition in the WHILE statement that make the loop end?

    I don't want to end the loop but a specific step at a condition and a loop continue.
  • einsTeIn.NET
    einsTeIn.NET Member Posts: 1,050
    Why not just like this?
    WHILE condition1 DO BEGIN
      IF condition2 THEN BEGIN
        ....
      END;
    END;
    
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • vijay_g
    vijay_g Member Posts: 884
    edited 2010-06-16
    Stan09 wrote:
    I don't want to end the loop but a specific step at a condition and a loop continue.

    use Break with a specific condition.

    if (condition) then
    break;
  • Stan09
    Stan09 Member Posts: 63
    Thanks you Einstein.net, it's work.
  • Shonatina
    Shonatina Member Posts: 114
    y not try something like this?

    record.find('-');
    repeat
    if record.age = 45 then
    break;
    until record.next <=0;

    And the syntax requires that you use CurrReport.BREAK (not case sensitive). If you leave off the CurrReport. prefix, you will get the error message, namely the compiler asking you to define the unknown variable "break".
    smile always
    shona
    That which you seek inside is that which you find outside
  • DenSter
    DenSter Member Posts: 8,307
    Another alternative
    WHILE condition1 OR Condition2 DO BEGIN
    END;
    
    or
    WHILE condition1 DO BEGIN
      REPEAT
      UNTIL Condition2
    END;
    
    There's no C/AL command to actually jump out of a loop. If you have to jump out, you'll have to create a function for the code inside and use EXIT.