Had a spare minute, so here is a quick outline:
IF
IF evaluates a test expression (shown in blue), and, if it returns anything non-nil, will proceed to evaluate a 'then' expression (shown in red). Should the test expression return nil, IF will evaluate the 'else' expression (shown in green) should this be supplied.
IF/THEN
(if [color=blue](this_is_true)[/color]
[color=red](do_this)[/color]
)
IF/THEN/ELSE
(if [color=blue](this_is_true)[/color]
[color=red](do_this)[/color]
[color=green](else_do_this)[/color]
)
The IF function can only take three arguments: the test expression, an expression to evaluate if the test expression returns non-nil, and an optional expression to evaluate if the test expression returns nil.
Hence, if we wish to evaluate mutiple expressions within the IF function, we can wrap these functions within a function such as progn which can be then supplied to IF as a single expression:
IF/THEN
(if [color=blue](this_is_true)[/color]
[color=red] (progn
(do_this)
(and_this)
...
(and_this)
)[/color]
)
IF/THEN/ELSE
(if [color=blue](this_is_true)[/color]
[color=red] (progn
(do_this)
(and_this)
...
(and_this)
)[/color]
[color=green] (else_do_this)[/color]
)
IF/THEN/ELSE
(if [color=blue](this_is_true)[/color]
[color=red] (progn
(do_this)
(and_this)
...
(and_this)
)[/color]
[color=green] (progn
(else_do_this)
(and_this)
...
(and_this)
)[/color]
)
COND
COND will evaluate a test expression (first item in a list of expressions) for each condition (list of expressions) supplied and evaluate the expressions following the test expression should it return non-nil. COND will stop evaluating test expressions when a condition is met.
(cond
(
[color=blue](if_this_is_true)[/color]
[color=red] (do_this)
(and_this)
...
(and_this)[/color]
)
(
[color=blue](else_if_this_is_true)[/color]
[color=red] (do_this)
(and_this)
...
(and_this)[/color]
)
(
[color=blue](else_if_this_is_true)[/color]
[color=red] (do_this)
(and_this)
...
(and_this)[/color]
)
...
)
This functionality could also be achieved using a tree of nested IF statements, however this is much less elegant and harder to follow:
(if [color=blue](this_is_true)[/color]
[color=red] (progn[/color]
[color=red] (do_this)
(and_this)
...
(and_this)[/color]
)
(if [color=blue](else_if_this_is_true)[/color]
[color=red] (progn[/color]
[color=red] (do_this)
(and_this)
...
(and_this)[/color]
)
(if [color=blue](else_if_this_is_true)[/color]
[color=red] (progn[/color]
[color=red] (do_this)
(and_this)
...
(and_this)[/color]
)
...
)
)
)
WHILE
WHILE will evaluate a test expression, and, if it returns a non-nil value, will evaluate a set of expressions; this is repeated until the test expression returns nil.
(while [color=blue](this_is_true)[/color]
[color=red] (do_this)
(and_this)
...
(and_this)[/color]
)
That's all for now!
Lee