Project

General

Profile

WHILE in Scol » History » Revision 2

Revision 1 (iri, 09/24/2012 11:59 PM) → Revision 2/3 (iri, 09/24/2012 11:59 PM)

h1. WHILE in Scol 

 *while* <condition> *do* instructions 

 <pre> 
 while <condition> do 
 ( 
	 instruction_1; 
	 instruction_2; 
	 instruction_3; 
	
	 instruction_n; 
 ); 
 </pre> 

 If the condition is false at the start, the instructions block is never ran. 

 Example : 
 <pre> 
 fun main ()= 
	 _showconsole; 
	
	 let 10 -> counter in 
	 while (counter >= 0) do 
	 ( 
		 _fooId counter; 
                 
		 set counter = counter-1      // do not forget to increase or decrease your counter, otherwise, the loop can become infinite 
		 set counter = counter-1 
	 ); 
	 0;; 
 </pre> 
	

 License : "CC-BY-SA-2.0":https://creativecommons.org/licenses/by-sa/2.0/ 
 Tutorial by iri 
 Updated by /