While

From EventScripts Community Encyclopedia

Overview

Syntax: while "<condition>" "<command>"

Note: Command parameters are described inside the < and > characters. Optional parameters are contained within [ and ] characters.

Variation of this command that doesn't expand variables: while

Description

Will execute command until the condition is not true.

Parameters

  • condition - Condition to check each time. Can compare values using:
    • equalto (==/=)
    • notequalto (!=)
    • greaterthan (>)
    • lessthan (<)
    • greaterthanorequalto (>=)
    • lessthanorequalto (<=)
  • command - Command to execute. Can be a single command or use es_doblock to do several commands.


Examples

If you had this code in a block somewhere:

es_xsetinfo max 3
es_xsetinfo i 0
while "server_var(i) < server_var(max)" "es_xdoblock script/while_loop"
Along with this code:
block while_loop
{
  es_msg i = server_var(i)
  es_xmath i + 1
}

It will display:

i = 0
i = 1
i = 2


Notes

  • This command exists in EventScripts v1.1 or higher.
  • Must call es_load corelib before using this command.
  • Does not support do or parens () around a condition, as in es_xif (condition) do {command}


See also

blog comments powered by Disqus