Programmer Guide/Command Reference/WHILE: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 4: Line 4:
  END
  END
or
or
  DO WHILE <var>condition</var>
  DO WHILE <var>[[Programmer_Guide/Concepts/Conditional_Expressions|condition]]</var>
     &hellip;
     &hellip;
  END
  END

Revision as of 15:50, 7 May 2014

WHILE condition
   …
END

or

DO WHILE condition
   …
END

Provided that the conditional expression condition holds true, the commands in the block enclosed by the WHILE, or DO WHILE, and the corresponding END statement are repeatedly executed until condition becomes false.

To put it more bluntly: The condition is always tested on the begin of the loop, that is, before executing the respective block of commands. With STx, there is no explicit loop statement checking its condition at the end of the loop, but if this is what you are longing for, you will find relief by combining the FOREVER statement with an appropriate IF, and BREAK, statement.

Note that it is perfectly legal to prematurely leave a loop with a GOTO statement, though, generally, GOTO is considered harmful.

Navigation menu

Personal tools