Command:/while

From the wonderful RedGuides Wiki

This command is added by MacroQuest

Syntax Key
Notation Description
Text without brackets or braces Required items
<Text inside angle brackets> Placeholder for which you must supply a value
[Text inside square brackets] Optional items
Vertical bar (|) Separator for mutually exclusive items; choose one
{Text | inside | braces} Set of required items; choose one
Ellipsis () Items that can be repeated
Syntax /while <condition> { <commands> ⮒ }
Description Executes commands while the expression condition evaluates to true. Note that } must be on a line by its own. You can end a /while loop immediately with /break or try the next iteration with /continue.

Options

Examples

/declare varname int 0
/while (${varname} < 5) {
  /varcalc varname ${varname}+1
  /echo ${varname}
}

Will output:

 1
 2
 3
 4
 5


/declare varname int 0
/while (${varname} < 5) {
  /varcalc varname ${varname}+1
  /if (${varname} == 3) /continue
  /echo ${varname}
}

Will output:

 1
 2
 4
 5


/declare varname int 0
/while (${varname} < 5) {
  /varcalc varname ${varname}+1
  /if (${varname} == 3) /break
  /echo ${varname}
}

Will output:

 1
 2

See also