LOOP: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "The '''LOOP''' statement denotes the end of a DO...LOOP where the program jumps to the beginning of the loop if the optional condition is true. {{PageSyntax}} :: DO ::. ::. ::. :: LOOP [{UNTIL|WHILE} ''condition''] * LOOP indicates the bottom or end of a DO...LOOP block of code. * Either the DO statement or LOOP statement can set a condition to end the loop. * When a loop uses a LOOP condition, the code inside of it will run at least ONCE. : *...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
The '''LOOP''' statement denotes the end of a [[DO...LOOP]] where the program jumps to the beginning of the loop if the optional condition is true.  
The '''LOOP''' statement denotes the end of a [[DO...LOOP]] where the program jumps to the beginning of the loop if the optional condition is true.




Line 10: Line 10:




* LOOP indicates the bottom or end of a [[DO...LOOP]] block of code.  
* LOOP indicates the bottom or end of a [[DO...LOOP]] block of code.
* Either the [[DO...LOOP|DO]] statement or LOOP statement can set a condition to end the loop.
* Either the [[DO...LOOP|DO]] statement or LOOP statement can set a condition to end the loop.
* When a loop uses a LOOP condition, the code inside of it will run at least ONCE.
* When a loop uses a LOOP condition, the code inside of it will run at least ONCE.
: * A [[WHILE]] condition continues the loop until the condition is false.  
: * A [[WHILE]] condition continues the loop until the condition is false.
: * An [[UNTIL]] condition continues the loop until the condition is true.
: * An [[UNTIL]] condition continues the loop until the condition is true.
: * If only DO and LOOP are used the loop will never end! '''Ctrl-Break''' can be used to stop an endless loop!
: * If only DO and LOOP are used the loop will never end! '''Ctrl-Break''' can be used to stop an endless loop!
Line 19: Line 19:




''See also:''
{{PageSeeAlso}}
* [[FOR...NEXT]] {counter loop)
* [[FOR...NEXT]] {counter loop)
* [[WHILE...WEND]] (loop)
* [[WHILE...WEND]] (loop)

Latest revision as of 00:47, 29 January 2023

The LOOP statement denotes the end of a DO...LOOP where the program jumps to the beginning of the loop if the optional condition is true.


Syntax

DO
.
.
.
LOOP [{UNTIL|WHILE} condition]


  • LOOP indicates the bottom or end of a DO...LOOP block of code.
  • Either the DO statement or LOOP statement can set a condition to end the loop.
  • When a loop uses a LOOP condition, the code inside of it will run at least ONCE.
* A WHILE condition continues the loop until the condition is false.
* An UNTIL condition continues the loop until the condition is true.
* If only DO and LOOP are used the loop will never end! Ctrl-Break can be used to stop an endless loop!


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage