2010

Table Of Contents
Two concepts are being introduced here:
The if statement allows a certain part of code to execute depending on a
condition. The section of code within the curly braces only executes if the
statement inside the parentheses evaluates to true.
The paired back-ticks within the parentheses (` `) indicate that the
commands within them are evaluated first. This is a useful part of writing
MEL code: you can make certain commands (here, the conditional
statement) dependent on other commands (here, the evaluation of whether
the window exists), which execute and evaluate first.
Together, the if statement and the evaluation mean that only if the result
of the window existence query is 1 (the window exists) is the window
deleted. Otherwise, the section of code within the curly braces is skipped.
Storing control names
If you refer to a control in your user interface, it must have a name. Instead
of manually specifying the name for each user interface element, you can
allow the command to generate unique default names and then you can store
the name as a variable.
All user interface commands return their full name and path upon creation.
You can store the return value as a variable to refer to the control at a later
point in the script.
To store a control name as a variable
1 Type the following in a MEL tab of the Script Editor:
window -resizeToFitChildren 1 pick_me_window; columnLayout;
$button_one=`button -label "Click Me!" -command "deleteUI
$button_two"`; $button_two=`button -label "NO!, Click Me!!"
-command "deleteUI $button_one"`; $button_close=`button -label
"Close" -command "deleteUI pick_me_window"`; showWindow;
688 | Chapter 13 Scripting in Maya