Functions Documentation |
|
Name |
block |
Syntax |
(block list exp1 ... expn) -> value of last expression |
Argument List |
list: A list of local variables. Can be Nil or empty. Can contain initial values.
exp1 ... expn: A series of expressions (anything you want to do). |
Returns |
Whatever the last expression in the block returns |
Category |
control structure
|
Description |
Allows you to run several expressions one right after the other. Also used to wrap variables that you want to be local. Those variables can be given default values using the syntax (variable value). See example for more details |
Example |
(block Nil
(block (A)
(setq A "value")
(block ((B "default") C)
; A, B, and C are valid here.
(dbgOutput A) ; prints "value"
(dbgOutput B) ; prints "default"
(dbgOutput C) ; prints "Nil"
; Setting a variable not declared
; in any parent's list makes a global:
(setq D "global")
)
; A is still valid here.
; B and C are invalid,
; and would cause errors.
(dbgOutput D) ; prints "global"
)
)
|
Comment |
This is a very important function because often you want to run things one right after another. It is one of the most if not the most common function in the xml. |