| function name | description |
|---|---|
| break | break out of a looping construct |
| continue | continue around a loop within a looping construct |
| do | perform a sequence of commands |
| doWhile | do a sequence of commands - maybe interrupted by break or continue statements |
| for | looping construct to work down a list or along an enumerator |
| if | simple conditional test |
| cond | powerful conditional test |
| return | return a value from a script function |
| set | assign a variable to hold the reference to the argument object |
| unset | remove any assignment for the supplied variable |
| setShared | put the supplied data into the shared region so that it can be easily shared across threads within the same process |
| getShared | get the supplied data from the shared region |
| while | loop while a given condition holds |
breakBreak out of a looping construct -- see the doWhile, for, while statements for further details.
Arguments: none
Return type: the empty List () is returned.
continueContinue around a looping construct -- see the doWhile, for, while statements for further details.
Arguments: none
Return type: the empty List () is returned.
doPerform a sequence of commands. For example:
(do
(print "Hello")
(messageBox "Ooops")
(print "there!")
)
Arguments: any number of expressions to be evaluated in sequence
Return type: the result of evaluating the final expression is returned
doWhilePerform a sequence of commands while the supplied condition evaluates to anything other than the empty List. Note that the condition is evaluated after the expressions have been evaluated.
This loop may be finished by the break statement, or the continue statement which interrupts the loop and goes round again without evaluating the remaining expressions.
For example:
(doWhile (> n 0)
(print n)
(set n (- n 1))
)
Arguments:
| condition | Object |
| ... | expressions to evaluate before testing if the condition holds |
Return type: the result of evaluating the final expression is returned
forLooping construct to work down a List or along an enumerator. For example:
(for x (list 1 2 3)
(print x)
(set x (* x x))
(print x)
)
The variable gets instantiated with the item in the List
or from working along the Enumerator. The expressions
are then evaluated in sequence.
This loop may be finished by the break statement, or the continue statement which interrupts the loop and goes round again without evaluating the remaining expressions.
Arguments:
| variableName | Symbol |
| obj | List or
Enumerator
|
| ... | expressions to evaluate |
Return type: the result of evaluating the final expression is returned
if
The simple conditional test. The empty List ()
is taken to mean false. Any other item is taken to mean true
in conditional tests.
For example:
(if (> x 100)
# here, we only have print if x is large!
(print "large")
)
(if (> x 0)
# print the word 'positive' is x is +ve
(print "positive")
# otherwise, x is -ve or zero
(print "negative or zero")
)
Arguments:
| condition | Object |
| thenExpr | Object |
| elseExpr (optional) | Object |
Return type: the empty List () is returned.
cond
The function cond provides a more powerful conditional test
than the if function. It takes 1 or more List
clauses where each clause typically consists of a test followed by a sequence of expressions to
evaluate if the test succeeds. The clauses are worked on in order. When the first test
expression evaluates to true then the following expressions within the clause are
evaluated -- the result of the final evaluation being returned.
If a clause contains just a test with no subsequent expressions, the value of the clause is the value of the evaluation of the test.
cond is most often used to produce a multiple if statement e.g.
(cond ( test1 expr1 )
( test2 expr2 )
...
( testN exprN )
)
Arguments:
| clause (multiple) | List |
Return type: an object of any type may be returned
return
Return a value from a script function. Whenever a return
expression is evaluated, the script function is terminated and the supplied
value returned.
Arguments:
| obj | Object |
Return type: any type can be returned
setAssign a variable to hold the reference to the argument object.
(set x 234)
Arguments:
| name | Symbol |
| value | Object |
Return type: the empty List () is returned.
A second, more powerful, form of the function can assign a list of variables to elements of a list e.g.
(set (x y z) (list 2 3 4))
assigns x to hold 2, y to hold 3 etc.
If the length of the values-list is greater than the length of the variables-list, then any remaining values in the values-list remain un-assigned.
unsetRemove any assignment for the supplied variable.
Arguments:
| name | Symbol |
Return type: the empty List () is returned.
setSharedPut the supplied data into the shared region so that it can be easily shared across threads within the same process.
(setShared "x" 234)
Arguments:
| name | String |
| value | Object |
Return type: the empty List () is returned.
getShared
Get the supplied data from the shared region -- see setShared.
(getShared "x")
Arguments:
| name | String |
Return type: the Object which was
previously put into the shared region using setShared.
whileLoop while a given condition holds. Note that the condition is evaluated and tested before the expressions are evaluated. For example:
(while (> x 0)
(print x)
(set x (- x 1))
)
This loop may be finished by the break statement, or the continue statement which interrupts the loop and goes round again without evaluating the remaining expressions.
Arguments:
| condition | Object |
| ... | expressions to evaluate while the condition holds |
Return type: the empty List () is returned.
| Contents | Index | Current topic: functions | Related topics: objects |