Special Notes About Function Calls

Functions in MAXScript are just another value that can be stored in variables and arrays, and passed to other functions as arguments. Such functions are sometimes called higher-order functions. All built-in functions, and functions that MAXScript defines based on the 3ds Max object classes, are values stored in system global variables of the same name as the function. When you define a scripted function, the function value is placed in a variable with the same name as the function. You can use the value in these variables and work with them as you would with other values, such as storing them in an array or passing them as arguments.

Because the function name is a variable that simply yields the function itself, functions that take no arguments need to be called in a special way.

FOR EXAMPLE,

if you want to call a function get_current_target that takes no arguments, you can not simply write:

   t = get_current_target

This stores the get_current_target function value in variable t , rather than storing the result of executing function get_current_target . Instead, you must use the "()" nullary call operator:

   t = get_current_target()

The function to be called is defined as an <operand> in the syntax for function calls. This means that it can bean expression that is evaluated to get the function to call.

FOR EXAMPLE,

   (if a > b then sin else cos) x --conditional function choice
   handlers= #(move, scale)
   x = 2
   handlers[x] $box01 [1,1,1] --get the function out of an array