Difference between revisions of "Command:While"

From Lavish Software Wiki
Jump to navigation Jump to search
Line 4: Line 4:
  
 
== Description ==
 
== Description ==
Used in conjunction with [[Command:Do|Do]] to create a While loop.  "While" marks the end of the loop, whereas "Do" marks the beginning. When this command is executed, the condition is checked.  If the condition is met then execution continues from [[Command:Do|Do]], otherwise continuing past While.
+
Conditionally returns execution to its matching [[Command:Do|Do]] command, effectively creating a loop, depending on the value of an expression. The condition is run through a [[LavishScript:Mathematical Formulae|math calculator]].  If the result is zero, execution continues after the While command; otherwise it returns to Do. A command blocks must be used between the Do and While, which begin with a '''{''' and end with a '''}'''.
 +
 
  
 
== Examples ==
 
== Examples ==
Line 20: Line 21:
 
*[[Command:Do|Do]]
 
*[[Command:Do|Do]]
 
*[[LavishScript:Commands|Commands]]
 
*[[LavishScript:Commands|Commands]]
 +
*[[LavishScript:Mathematical Formulae|Mathematical Formulae]]
 +
 
{{Command-Stub}}
 
{{Command-Stub}}
 
[[Category:LavishScript]]  
 
[[Category:LavishScript]]  
 
[[Category:LavishScript Commands]]
 
[[Category:LavishScript Commands]]

Revision as of 14:23, 26 June 2005

Syntax

Command Difficulty Rating
While
Usage Intermediate
Level of Understanding Intermediate
Computer Savvy Beginner
Logic Intermediate

While <condition>

Description

Conditionally returns execution to its matching Do command, effectively creating a loop, depending on the value of an expression. The condition is run through a math calculator. If the result is zero, execution continues after the While command; otherwise it returns to Do. A command blocks must be used between the Do and While, which begin with a { and end with a }.


Examples

Declare Count int 1
Do
{
  Echo ${Count}
  VarCalc Count ${Count}+1
}
While "${Count}<10"

See Also