Datasheet
8
Chapter 1 Customization and MEL Scripting
determined by a closing curly bracket }. In the case of newcam.mel, the closing curly bracket is
on the last line of the script.
A procedure is not activated until it is called. Executing the procedure name in the
Script Editor work area is one way to call a procedure. This assumes that the procedure
is global, which is determined by the inclusion of the word
global. Once a procedure is
global, you can call it from any part of a script that is not part of the procedure. That is,
you can call global procedures from non-procedure parts of the script, from other pro-
cedures, or as a command listed by a button or menu item. If variables (symbolic names
that hold values) are set up correctly within the script, the
global option is not necessary
and procedures become local. For a deeper discussion of global and local variables and
when to use them, see Chapter 3.
Another feature of the
newcam.mel script is the use of three collapsible frames (indicated
by the down-pointing arrows on the left side of the window). To create a collapsible frame,
code similar to the following is needed:
frameLayout -collapsable true -label βframe nameβ
-width 250;
rowLayout -numberOfColumns 3 -columnWidth3 100 100 100;
[text, buttons, or fields go here]
setParent ..;
setParent ..;
The two setParent commands are necessary for the frame to function. You can place as
many frames as you like in a window so long as each
frameLayout command has two match-
ing
setParent commands. In addition, each frame must have its own layout command; in
this example,
rowLayout is used. The -numberOfColumns flag indicates the number of columns
within the frame. The
-columnWidth3 flag indicates the pixel width of each column; a pixel
width of 100 is set by including
100 100 100 after the flag. Although these are optional flags,
they make the results much cleaner.
Retrieving Values from Fields
One of the trickier aspects of MEL scripting is the creation of numeric fields in which users
can enter new values.
newcam.mel creates two of these: one in the Lens frame and one in the
Clip frame. The following line creates the Lens field and establishes the size of the camera lens:
string $holdera =`intField -width 45 -value 25
-minValue 25 -maxValue 250
-changeCommand βint $cam_lens = `intField -query
-value enteredValuea`β enteredValuea`;
07405c01.indd 807405c01.indd 8 1/17/07 8:30:50 PM1/17/07 8:30:50 PM