Anvil | Smiths Smiths | Register Register | Login Login |
Search:
Show links Show tools Show tree | Previous document Next document | njet.org > Anvil > Documentation > Language reference > Statements > Compound statements > For

For

For statement is conditional repeat statement: contained statement is repeated as long as the condition expression evaluates to "true".

For statement consists of three parts, all of which are optional:

  • Initialization, evaluated once before entering to checking the condition.
  • Condition, evaluated during each time during repeat cycle, also when statement is entered. If condition is missing ``true´´ is used.
  • Action, evaluated before condition is checked, but before first condiition check.

A break statement will terminate execution of loop, while continue skips rest of statements in body and goes back to testing the condition, although action is evaluated before condition.

  for := "for" "(" forexprs ")" statement 
  forexprs := [ forexpr-listinit ] ";" [ exprcondition ] ";" [ forexpr-listaction ]  
  forexpr-list := expr-start ( "," expr-start ) * 
See also  | Statements  | Break  | Continue  | Compound statements  | Tags  | <for>  | Statement labels  | Grammar
Contributes notes:
Add a note
What's new | Anvil