User Tools

Site Tools


modding:function:block

block

block

block

Syntax (block list exp1 … expn) → value of last expression
Arguments 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 as one group - for example as either the 'true' or 'false' expression of an if function. 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 (varA)
    (setq varA "varA")
    (block ((varB "varB") varC)
      (dbgOutput "varC, varB and varA are valid here. varB has a default value, varC is Nil")
    )
    (dbgOutput "varA is valid here. varB and varC are invalid and would cause errors to use.")
  )
)

Return to Functions list

modding/function/block.txt · Last modified: 2014/12/27 04:40 by 127.0.0.1