Programmer Guide/Command Reference/WHILE: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
==WHILE==
WHILE <var>[[Programmer_Guide/Command_Reference_Intro/Conditional_Expressions|condition]]</var>
    ...
END
or
DO WHILE <var>condition</var>
    ...
END
Provided that the [[Programmer_Guide/Command_Reference_Intro/Conditional_Expressions|conditional expression]]<code>condition</code> holds true, the commands in the block enclosed by the <code>WHILE</code>, or <code>DO WHILE</code>, and the corresponding <code>END</code> statement are repeatedly executed until <code>condition</code> becomes false.


<code>WHILE | DO WHILE <var>condition</var></code>
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 S_TOOLE-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 [[Programmer_Guide/Command_Reference/FOREVER|FOREVER]] statement with an appropriate Programmer_Guide/Command_Reference/IF|IF]], and [[Programmer_Guide/Command_Reference/BREAK|BREAK]], statement.
 
Repeat commands in the DO block while <var>condition</var> is true. The argument <var>condition</var> has the same format and meaning as described for the command <code>[[User Guide/Workspace/Parameter Processing|IF]]</code>. The condition is always tested on the begin of the loop.

Revision as of 17:09, 23 March 2011

WHILE condition
   ...
END

or

DO WHILE condition
   ...
END

Provided that the conditional expressioncondition 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 S_TOOLE-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 Programmer_Guide/Command_Reference/IF|IF]], and BREAK, statement.

Navigation menu

Personal tools