While Loop

Hi' All

How to  exit  while loop and continue next command ?

Example    

    VAR num sum;
    PROC testwhile()
        WHILE TRUE DO
            Incr sum;
            IF sum = 10 THEN
                TPWrite "Sum :" \Num:= sum;
                ! ----------  Exit while loop and continue command
            ENDIF 
        ENDWHILE
    ENDPROC

PROC summ()
    testwhile;
   TPWrite "Exit loop while";
ENDPROC

Thanks for help.

Comments

  • Hello
    There is no break command but you could set a condition for the while loop like WHILE  NOT sum = 10 THEN
    /Pavel
  • PerSvenssonPerSvensson Sweden ✭✭✭
    Something like this

        VAR num sum;
        VAR bool bExit:=FALSE;

        PROC testwhile()
            WHILE NOT bExit DO
                Incr sum;
                IF sum = 10 THEN
                    TPWrite "Sum :" \Num:= sum;
                    bExit:=TRUE;
                    ! ----------  Exit while loop and continue command
                ENDIF 
            ENDWHILE
        ENDPROC

    PROC summ()
        testwhile;
       TPWrite "Exit loop while";
    ENDPROC
    Per Svensson
    Robotics and Vision Specialist
    Consat Engineering
  • SamuchaSamucha Thailand
    Hi,All

    Thanks for help.
Sign In or Register to comment.