While...Wend: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
No edit summary
No edit summary
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
WHILE ''condition'' <br />
While ''condition'' <br />
:::[''statements''] <br />
:::[''statements''] <br />
WEND
Wend


'''Description'''
== Description ==


WHILE...WEND repeats a group of statements while a given condition is TRUE. The required component, ''condition'', is any valid expression that evaluates to TRUE or FALSE. The optional component, ''statements'', are executed during each iteration of the loop. WHILE...WEND statements can be nested, and any WEND statements in a nested loop transfer execution to one level above the loop where the WEND occurs.
While...Wend repeats a group of statements while a given condition is TRUE. The required component, ''condition'', is any valid expression that evaluates to TRUE or FALSE. The optional component, ''statements'', are executed during each iteration of the loop. While...Wend statements can be nested, and any Wend statements in a nested loop transfer execution to one level above the loop where the Wend occurs.


'''Example'''
== Example ==


<pre>
<tabber>
REM WHILE...WEND Example
JavaScript=
'WHILE...WEND repeats a group of statements
<syntaxhighlight lang="JavaScript">
DIM Counter
// While...Wend Example
/* While...Wend repeats a group of statements */
 
var Counter = 1;
while (Counter < 5) {
  NSB.Print("Counter = " + Counter);
  Counter++;
}
</syntaxhighlight>
|-|
BASIC=
<syntaxhighlight lang="vb.net">
Rem While...Wend Example
'While...Wend repeats a group of statements
 
Dim Counter
Counter = 1
Counter = 1
WHILE Counter < 5
While Counter < 5
   PRINT "Counter = " & Counter
   Print "Counter = " & Counter
   Counter = Counter + 1
   Counter = Counter + 1
WEND
Wend</syntaxhighlight>
</pre>
</tabber>


'''Output'''
== Output ==


<pre>
<pre>
Line 29: Line 44:
</pre>
</pre>


'''Related Items'''
== Related Items ==
 
[[do...loop|Do...Loop]], [[for...next|For...Next]], [[for each...next|For Each...Next]]
 
[[Category:Language Reference]]


[[do...loop|DO...LOOP]], [[for...next|FOR...NEXT]], [[for each...nex|FOR...EACH...NEXT]]
[[Category:Statements - Flow of control]]

Latest revision as of 23:36, 24 July 2019

While condition

[statements]

Wend

Description

While...Wend repeats a group of statements while a given condition is TRUE. The required component, condition, is any valid expression that evaluates to TRUE or FALSE. The optional component, statements, are executed during each iteration of the loop. While...Wend statements can be nested, and any Wend statements in a nested loop transfer execution to one level above the loop where the Wend occurs.

Example

// While...Wend Example
/* While...Wend repeats a group of statements */

var Counter = 1;
while (Counter < 5) {
  NSB.Print("Counter = " + Counter);
  Counter++;
}

Rem While...Wend Example
'While...Wend repeats a group of statements

Dim Counter
Counter = 1
While Counter < 5
  Print "Counter = " & Counter
  Counter = Counter + 1
Wend

Output

Counter = 1
Counter = 2
Counter = 3
Counter = 4

Related Items

Do...Loop, For...Next, For Each...Next