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:
expression is evaluated in
the course of running a function body, the function exits
immediately and yields the value given in the return
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.
special case, you can exit a script controller’s script using
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.