Learning MAXScript > Creating Your Own Scripts >

# Saving Your Commands in a Script File

So far, you have entered your commands into the Listener window. If you had to stop at some point, and couldn't finish some code in one session, you would have to start all over, entering the commands you already used in the previous session. MAXScript allows you to store your commands in an external file that you can load and run.

The general procedure for storing commands in a script file is to click the New Script menu item in the MAXScript menu, and type commands in the Script Editor window that opens. Because you have already entered a lot of commands in the Listener window, you can copy them from that window into the Script Editor window.

To copy tutorial commands from the Listener into the script editor window:

1. Click the New Script menu item in the MAXScript menu in the 3ds Max Main Menu bar.

   The Script Editor window appears with the title "(Untitled) - MAXScript".

2. Position the Script Editor window side-by-side or below the Listener window so that you can copy and paste text between the two windows.

3. In the Listener window, select the black command line from the Drawing a Box with MAXScript topic (mybox = box length:20 width:20 height:20)

4. Press Ctrl+C on your keyboard to copy the text to the Clipboard.

5. Click the Script Editor window to place the cursor in it, and press Ctrl+V on your keyboard to paste the command into the Script Editor window.

   Tip: You can also drag selected text from the Listener and drop it in the Script Editor, or vice versa.

6. Choose File > Save in the Choose File Name for Save dialog, navigate to your \Scripts directory. Name your script file box_draw.ms and click Save.

   Your script file is saved and the script editor window title changes to "box_draw.ms - MAXScript."

You have now saved your first script file. MAXScript uses the .ms extension for script files. It is good general practice to save all of your script files into the scripts directory.

Next Topic

Loading and Running your Script File