The Return Expression

As with the loop constructs, you can break out of a function body block-expression prematurely in MAXScript, and return a result without evaluating the remaining portion of the block.

For this purpose, you use the return expression:

return <expr>

If a return expression is evaluated in the course of running a function body, the function exits immediately and yields the value given in the return <expr>.


fn find_root twod_fn =


local root, last_root

while true do



if abs(root - last_root) < epsilon then return root






It is unnecessary to place a return expression at the end of a function body to return an expression value. Instead, simply place the result expression at the end of a function body.

If a return <expr> is used in a mapped function and a collection is passed as the first argument to the function, the value returned will be OK rather than <expr>.

As a special case, you can exit a script controller’s script using a return <expr>.

In 3ds Max 6 and higher

You can call return() in macroScripts whose body is a single expression (i.e, old style MacroScripts that do not implement 'on execute do ...' handler) to exit the MacroScript.