MAXScript Introduction > The MAXScript Editor > MAXScript Legacy Editor Windows >

# The MAXScript Legacy Editor Windows

NoteThis topic describes the MAXScript Legacy Editor Windows used in versions prior to 3ds Max 2008. Some areas of MAXScript in 3ds Max 2008 and higher such as Particle Flow Script Operators and the newScript() method still open instances of the Legacy Editors.For documentation of the new MAXScript Editor, see MAXScript Tabbed Editor Window

MAXScript Editor windows are text editor windows you can open within 3ds Max and use to create or edit text files, notably MAXScript script files. Press Open Script on the MAXScript rollout, File > Open Script in the Listener menu bar, or MAXScript > Open Script in the 3ds Max menu bar to open an existing script file. MAXScript opens the selected script in a modeless MAXScript Editor window, such as the one shown.

To create a fresh script, press New Script on the MAXScript rollout, File > New Script in the Listener menu bar, or MAXScript > New Script in the 3ds Max menu bar to open a new, empty MAXScript Editor window. You can write and edit text, including drag-and-drop editing, in the MAXScript Editor as you would in other editors like WordPad. The menus are similar to those in many standard Windows text editors. You may have any number of MAXScript Editor windows open at the same time.

MAXScript Editor is suited to developing longer scripts or code fragments you want to keep. You can edit and test parts of them until they are complete, then save your code in a script file for later use. This is a common method for developing large scripts, utilities, and function libraries.

You can select one or more text lines and drag them to a 3ds Max toolbar to create a Macro Script containing the selected lines. For more information, see Defining Macro Scripts.

You can open a MAXScript Editor window from within the Listener or from other running scripts by calling the edit() method.

The syntax for the edit() method is:

    edit <filename_string>

where <filename_string> is a string literal or an expression that evaluates to a string, and specifies the name of the file whose contents are to be loaded into the new MAXScript Editor window.

EXAMPLE
    edit"my_script.ms"
or
    scriptfile="my_script.ms"
    edit scriptfile

The file will be searched for in the following directories, in the order listed:

- The current MAXScript directory

- The 3ds Max executable main directory

- The Windows NT 32-bit system directory (system32)

- The Windows 16-bit system directory (system)

- The Windows directory

- The directories that are listed in the PATH environment variable

You can create an empty MAXScript Editor window from within the Listener or from other running scripts by calling the newScript() method.

The syntax for the newScript() method is:

    newScript()

Opens an empty MAXScript Editor window and returns a WindowStream value that may be used as the target for print and format operations. This is useful for directing output to a separate window for ease of inspection or editing, or later saving to a file. Output to a WindowStream is inserted at the current cursor position in that window.

NoteIn 3ds Max 2008 and higher, the newScript() method still creates a Legacy Editor and not a new tab in the new Editor.

FOR EXAMPLE:
    debug = newScript()
    ...
    print $foo to:debug
    ...
    format "name is %\n" obj.name t:debug

## The Legacy MAXScript Editor window has the following features:

- Titles that display only the current script's file name, rather than its full path name, so minimized MAXScript Editor windows can be easily distinguished.

- A line selection margin at the left window border. When you move the cursor into the left margin, it changes to a right-pointing arrow. A single-click selects an entire line, and click-dragging selects multiple lines.

- Drag-and-drop for moving and copying text to and from other MAXScript Editor windows, the Listener window, or any other text editor window that supports Window’s drag-and-drop. Simply dragging the text will move it. Holding down Ctrl while dragging will copy the text.

- Selected text is loaded automatically into the search text dialog field when you choose Search > Find or Search > Replace. This is useful for quickly finding other occurrences of the selected text.

- Selected text is loaded automatically into the Index field of this Online Reference - highlight a keyword in the MAXScript Editor and press the F1 button to open the Online Reference and search for information on the selected keyword.

- Syntax Coloring- manual syntax coloring is supported, in addition, in 3ds Max 5 and higher, automatic syntax coloring will be performed when opening files and for the current line while typing in the Editor.

- Bracket Balancing-place the cursor next to a bracket and press Ctrl+B to select all the text between this bracket and its corresponding counterpart.

- Quick source code navigation-hold down the Ctrl key and right-click in the MAXScript editor to display a context menu listing all major building blocks of the currently loaded script including functions, rollouts, event handlers, UI elements and more.

- Variable text size -hold down the Ctrl key and turn the mouse wheel (if available) to adjust the size of the source code text.

For commands use within the MAXScript Editor window, see MAXScript Editor Commands.