Skip to content
Haru edited this page Oct 19, 2016 · 1 revision

Syntax

  • do { <statement></statement>; } while (<condition></condition>);

Description

The do...while' is the only post-test loop structure available in this script language. With a post-test, the statements are executed once before the condition is tested. When the condition is true, the statement(s) are repeated. When the condition is false, control is transferred to the statement following the do...while' loop expression.

do &amp;&#35;123&#59;
	Code to execute(1)
&amp;&#35;125&#59; while (expression(2))&amp;&#35;59&#59;
Example 1&amp;&#35;58&#59; sentinel&amp;&#35;45&#59;controlled loop
	mes &amp;quot&#59;This menu will keep appearing until you pick Cancel&amp;quot&#59;&amp;&#35;59&#59;
	do &amp;&#35;123&#59;
		set .@menu, select(&amp;quot&#59;One&amp;&#35;58&#59;Two&amp;&#35;58&#59;Three&amp;&#35;58&#59;Cancel&amp;quot&#59;)&amp;&#35;59&#59;
	&amp;&#35;125&#59; while (.@menu &amp;&#35;33&#59;&amp;&#35;61&#59; 4)&amp;&#35;59&#59;
Example 2&amp;&#35;58&#59; counter&amp;&#35;45&#59;controlled loop
	mes &amp;quot&#59;This will countdown from 10 to 1.&amp;quot&#59;&amp;&#35;59&#59;
	set .@i, 10&amp;&#35;59&#59;
	do &amp;&#35;123&#59;
		mes .@i&amp;&#35;59&#59;
		set .@i, .@i &amp;&#35;45&#59; 1&amp;&#35;59&#59;
	&amp;&#35;125&#59; while (.@i &amp;gt&#59; 0)&amp;&#35;59&#59;

Category:Script Command

Clone this wiki locally