<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wiki.herc.ws/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.herc.ws/w/index.php?action=history&amp;feed=atom&amp;title=While</id>
		<title>While - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.herc.ws/w/index.php?action=history&amp;feed=atom&amp;title=While"/>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/w/index.php?title=While&amp;action=history"/>
		<updated>2026-05-05T03:27:11Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.21.11</generator>

	<entry>
		<id>https://wiki.herc.ws/w/index.php?title=While&amp;diff=477&amp;oldid=prev</id>
		<title>Via: Created page with &quot;== Syntax == * while (&lt;condition&gt;) &lt;statement&gt;;  == Description == This is probably the simplest and most frequently used loop structure. The 'while' statement can be inte...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/w/index.php?title=While&amp;diff=477&amp;oldid=prev"/>
				<updated>2013-06-10T22:22:51Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Syntax == * &lt;a href=&quot;/wiki/While&quot; title=&quot;While&quot;&gt;while&lt;/a&gt; (&amp;lt;condition&amp;gt;) &amp;lt;statement&amp;gt;;  == Description == This is probably the simplest and most frequently used loop structure. The &amp;#039;while&amp;#039; statement can be inte...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Syntax ==&lt;br /&gt;
* [[while]] (&amp;lt;condition&amp;gt;) &amp;lt;statement&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
This is probably the simplest and most frequently used loop structure. The 'while' statement can be interpreted as &amp;quot;while &amp;lt;condition&amp;gt; is true, perform &amp;lt;statement&amp;gt;&amp;quot;. It is a pretest loop, meaning the conditional expression is tested before any of the statements in the body of the loop are performed. If the condition evaluates to false, the statement(s) in the body of the loop is/are never executed. If the condition evaluates to true, the statement(s) are executed, then control transfers back to the conditional expression, which is reevaluated and the cycle continues. &lt;br /&gt;
&lt;br /&gt;
Multiple statements can be grouped with { }, curly braces, just like with the 'if' statement.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
 while ([[switch]]([[select]](&amp;quot;Yes:No&amp;quot;) == 2 ))&lt;br /&gt;
 	[[mes]] &amp;quot;You picked no.&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
=== Multiple Statements ===&lt;br /&gt;
 while (switch(select(&amp;quot;Yes:No&amp;quot;) == 2 )) {&lt;br /&gt;
 	mes &amp;quot;Why did you pick no?&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;You should pick yes instead!&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Counter-Controlled Loop ===&lt;br /&gt;
 set .@i, 1;&lt;br /&gt;
 while (.@i &amp;lt;= 5) {&lt;br /&gt;
 	mes &amp;quot;This line will print 5 times.&amp;quot;;&lt;br /&gt;
 	set .@i, .@i + 1;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Sentinel-Controlled Loop ===&lt;br /&gt;
 mes &amp;quot;Input 0 to stop&amp;quot;;&lt;br /&gt;
 [[input]] .@num;&lt;br /&gt;
 while (.@num != 0) {&lt;br /&gt;
 	mes &amp;quot;You entered &amp;quot; + .@num;&lt;br /&gt;
 	input .@num;&lt;br /&gt;
 }&lt;br /&gt;
 [[close]];&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Loops#While_Loop]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Script Command]]&lt;/div&gt;</summary>
		<author><name>Via</name></author>	</entry>

	</feed>