Controlling Program Flow

MAXScript has several <expr> expression forms used to explicitly control the flow of execution. They are:

<if_expr>

<case_expr>

<do_loop>

<while_loop>

<for_loop>

<loop_exit>

<try_expr>

These expression forms correspond to the standard control constructs found in many programming languages. Each is described in its own topic:

If Expression

Case Expression

While and Do Loops

For Loop

Loop Exit

Try Expression

Additionally, there are several constructs for implicitly controlling program flow.

The when construct is used for scripting general change handlers, so you can write scripts that respond to user operations such as object moves, vertex edits, object deletions, name changes, and so on. Callback mechanisms are used to have a function called when certain specific events occur. See Change Handlers and When Constructs for more information.

The on construct is used when scripting rollouts or tools or plugins, so the script can respond to events, often user-generated, in those constructs. See Utility and Rollout Properties, Methods, and Event Handlers for more information.