A function can take two kinds of arguments:
PositionalArguments. If you call a function that takes positional arguments, you must specify those arguments first and in the correct order. Positional arguments correspond to the function arguments in most programming languages - they are required and have a fixed number and order.
Keyword Arguments. You write keyword arguments as a keyword:<value> pair, and they can appear in any order after the positional arguments. Functions can use some or all of their keyword arguments as optional arguments. If you call a function and don't supply optional keyword arguments, they will have either the default value supplied by the called function, or the special value unsupplied when first referenced in the called function.
Optional keyword arguments are useful in command languages where commands can have many options. They are particularly useful within 3ds Max where most functions have numerous optional keyword arguments. For example, all scene object creation functions take optional keyword arguments for their creation parameters. As there are sometimes more than 100 arguments to these functions, using positional arguments would simply be unworkable.
As an example of positional arguments, the syntax for the print function is:
<value> is a positional argument, and is required. to: <file> is an optional keyword argument, where to is the argument keyword and <file> is the argument value. If the to argument value is unsupplied , MAXScript outputs <value> to Listener. Otherwise, MAXScript outputs <value> to the file specified by <file>.
EXAMPLE |
As another example, you can create a sphere object in the 3ds Max scene with no arguments: |
Or, you could specify just one argument: |
Or, you can specify more optional arguments: |
For those keyword arguments not specified when creating 3ds Max objects, default values are used. The default value used for each keyword argument is shown in the descriptions of the object classes.