DOIF

From Creatures Wikia

Jump to: navigation, search

DOIF is a CAOS command controlling flow.

Usage

Syntax: DOIF cond (condition) ..

DOIF is part of a set of commands used for conditional execution of code. It marks the start of a code block to execute if cond is true. It must be followed by another conditional execution marker: ELIF, ELSE or ENDI.

Some valid patterns for DOIF.. code are:

  • DOIF .. ENDI
  • DOIF .. ELSE .. ENDI
  • DOIF .. ELIF .. (ELIF ..) ENDI
  • DOIF .. ELIF .. (ELIF ..) ELSE .. ENDI

where .. indicates a code block for execution under conditions.

Examples

Here is a simple way of using DOIF and its confederates. If the current pose is 0, change it to 1; if it is 3, change it to 2; in any other case, change it to 5.

* change an agent's pose depending on how it looks now.
DOIF POSE eq 0
  POSE 1
ELIF POSE eq 3
  POSE 2
ELSE
  POSE 5
ENDI

DOIF is an important part of the CAOS language and many examples for other commands and functions use it. For instance, see the ROT13 script on CHAR, the implementation of SINS, and the third example in ATTR.

See also

Personal tools