In In The flow chart is as follows: In the above flow chart, we can see that in The following example loops the output Execute the above code, and the output is as follows: Lua programming language, the while loop statement repeatedly executes the loop body statement when the condition is determined to be true . 4.7.1. Grammar #
Lua programming language while loop syntax:while(condition) do statements end
statements (loop body statement) can be one or more statements condition can be any expression, in the condition is true , the loop body statement is executed.
condition (condition) is false skips the current loop and starts the script to execute the statement that follows. 4.7.2. Example #
a value:Example #
a=10 while( a < 20 ) do print("The value of a is:", a) a = a+1 end
The value of a is: 10 The value of a is: 11 The value of a is: 12 The value of a is: 13 The value of a is: 14 The value of a is: 15 The value of a is: 16 The value of a is: 17 The value of a is: 18 The value of a is: 19