Mel Quick Reference I
来源:互联网 发布:重庆java培训机构 编辑:程序博客网 时间:2024/05/07 22:22
Mel
Quick Reference I
return to main index
index
- setting variables
- using arrays
- using vectors
- if-else
- for loops
- querrying
- using the eval command
- create a window
- using column layout
- assigning a command to a button
- switch - branch
print "hello world";float $val = 1.5;print $val;
Print the contents of a string literal. Print the value of a variable.
Setting Variables
int $age = 54;float $pi = 3.142;string $hi = "good-day";vector $xyz = <<1, 0, 0>>;float $coord[] = {0.6, 0.3};
age is assigned the integer 54 pi is assigned the fractional value 3.142 hi is assigned a string literal xyz is assigned a vector of 3 values coord is assigned an array of 2 values
Using Arrays
int $ages[3]; // or $ages[]$ages = {25, 33, 45};$ages[0] = 12;print $ages;print $ages[2]; string $names[] = `ls -cameras`;int $num = size($names);print("Num Cameras = " + $num);
declare an integer array of three elements assign three values change the value of the first element print all three values print the last value get the names of the all the cameras size() counts the elements of an array print a confimation of the number of cameras
Using Vectors
vector $p = <<1, 2, 3>>;sphere -pivot ($p.x) ($p.y) ($p.z);
declare a vector - must have 3 components note the use of parentheses WRONG - cannot change an individual component RIGHT
if-else tests
tring $name[] = `ls -selection`;if(size($name) >= 1) print("Selection 1 = " + $name[0]);else print("Nothing selected"); if(gmatch($name[0], "nurbs*")) print("Found a nurbs object");
get the names of the selected objects does the array of names have at least one item? if so, then output the name otherwise print a warning use gmatch() to see if the name begins with the word "nurbs" - notice the use of the wild card *
for loops
sstring $names[] = `ls -selection`;for($i = 0; $i < size($names); $i++) print($names[$i] + "\n"); string $item;for($item in $names) print($item + "\n")
get the names of the selected objects for each element in the array of names ...output the name a more convenient way of dealing with an array is to use the "for in" variation of a for loop
Querrying
cone;float $rad = `cone -q -radius`; string $names[] = `ls -lights`;print $names;
make a default nurbs cone querry its radius and assign its value to $rad use the ls command to list the lights in a scene print the array of light names
Using the eval Command
string $cmd = "curve -p 0 0 0 -p 1 0 0 \-p 1 4 0 -p -1 2 3";string $pnt = "-p 3 3 3";string $name = eval($cmd + $pnt);print $name;
make a string variable containing text for a command (the backslash enables a string to go onto two lines) make another string containing some extra info use eval to execute the combined strings print the name returned from the "curve" command
Create a Window
window -title "test" myWindow;showWindow myWindow;
Create a window titled "test", to be identified as "myWindow" show the window.
Using Column Layout
window -title "test" myWindow;columnLayout;button;showWindow myWindow;
Create a window titled "test", to be identified as "myWindow" use the column layout manager add a button show the window.
Assigning a Command to a Button
vector $pnts[];string $ball = "curve ";for($i = 0; $i < 200; $i++) { $pnts[$i] = <<rand(-5,5), rand(-5,5), rand(-5,5)>>; $ball += " -p " + $pnts[$i]; }window -title "test";columnLayout; button -label "make hairball" -command "eval($ball)";showWindow;
declare an array of vectors declare a string to command text create 200 CV's
Create a window titled "test" use the column layout manager add a button with a title and a command
show the window
switch
int $x = 2;switch ($x) { case 0: print "zero"; break; case 1: print "one"; break; case 2: print "two"; break; default: print "no match"; }
Assign x the value 2. Attempt to match the value of x to the following,
0
1
2
No match, then do this default action.
© 2002- Malcolm Kesson. All rights reserved.
- Mel Quick Reference I
- Mel Quick Reference II
- SQL Quick Reference
- UML Quick Reference
- Chapter 1 Quick Reference
- actionscript quick reference
- DNN - skin quick reference
- VIM QUICK REFERENCE CARD
- LotusScript Language Quick-reference
- Vi Quick Reference
- LVM commands-quick reference
- bash Quick Reference
- XPath Functions Quick Reference
- CCNP Quick Reference
- Python 2.5 Quick Reference
- Emacs Quick Reference
- SVN Quick Reference
- Video Resolution Quick Reference
- sql 查询多项内容,要求某个字段内容不重复 及查某字段 重复的记录
- adb命令
- UIImagePickerController详解
- SQL学习网址
- 因为曾经是朋友
- Mel Quick Reference I
- Android 彻底解决sdk下载慢(失败)的问题
- 飞秋的“破”记忆
- Bila saya menulis k
- PostgreSQL数据库
- Android 属性动画(Property Animation) 完全解析 (上)
- R语言如何读取文件详解
- extern C的作用
- 安全科普:密码学之碰撞攻击