2010

Table Of Contents
Strings cant be split up over multiple lines without the use of a special
character. To split a string over multiple lines, use the back slash (\) character.
For example:
print "With the \\ character, you can \ split a string over \
multiple lines.";
To have a backslash appear in a string, you must use a double backslash. The
backslash character is an escape character. Escape characters tell the script
interpreter that the character that follows is literal. Certain special symbols
can be created using the escape character in combination with other characters.
For example, to display quotes within a string:
print "Jim said \"Hello!\" to the Maya user";
Window naming
As user interface scripts get more complex, it is possible that you may make
a syntax error. If a user interface script partially executes and halts on an error,
the window still exists, but the window is not visible. If you fix the problem
and would like to execute the script again, you must either give the window
a new name, or delete the hidden window.
Resolving naming conflicts
In the next section, you use conditional statements to resolve window naming
conflicts. Conditional statements allow a section of code to execute depending
on the value of a variable or the state of an object in the scene.
To resolve conflicting window names
1 Create a window with a scripting error inserted before the showWindow
command by typing the following in a MEL tab of the Script Editor:
window testwindow; fake_command; showWindow;
An error is output to the Script Editor.
// Error: line 2: Cannot find procedure "fake_command;". //
The window is not displayed, but still exists.
2 Create another window with the same name by typing the following in
a MEL tab of the Script Editor:
window testwindow; showWindow;
An error is output to the Script Editor.
686 | Chapter 13 Scripting in Maya