AutoIt+
  • Overview
  • Getting started
  • The language
    • Basic
    • Grammar
      • Expressions
      • Statements
      • Declarations
    • Operators
    • Variables
    • Types & values
      • Null
      • Booleans
      • Numbers
      • Strings
      • Functions
      • Classes
      • Pointers
    • Control flow
      • If statement
      • For loop
      • While loop
      • Break & continue
      • Error handling
    • Collections
      • Array
        • APIs
        • Implementation
      • Map
        • APIs
        • Implementation
    • Modules
    • Exceptions
  • Built-in modules
    • C
      • APIs
      • Constants
    • Math
      • APIs
      • Constants
    • Task
      • Types
      • APIs
    • Global
  • The aup
    • Compiler
    • Runtime
    • Options
Powered by GitBook
On this page
  • Syntax
  • Examples

Was this helpful?

  1. The language
  2. Control flow

While loop

Syntax

while <cond> <body>
  • cond is a expression

  • body is a statement

Examples

One-line loop

var i = 0
while i < 10 { i++ }

puts i    // 10

Single statement, no block

var i = 0
while i < 10: i++

20th fibonacci number

var n = 20
var a = 1, b = 0, c

while n-- > 0 {
    c = a
    a = a + b
    b = c
}

puts b

Infinite loop

while true {
    // Do sonething
}

Avoid to use infinite loop, which will make your program stuck.

PreviousFor loopNextBreak & continue

Last updated 3 years ago

Was this helpful?