Cheatsheet
|
|
-
The following is a brief summary of the basic functions in MEL.
print - Prints any given text string in the Scripting Window
print(text string)
| example: |
print("Hello!!");
|
|
if - Test if something is true and execute a piece of code
if([test clause]){
...stuff to execute if [test clause] is true
}
| example: |
if($i == 1){
print("i equals 1");
}
|
|
if-else - Test if something is true and execute a piece of code, otherwise execute something else
if([test clause]){
...stuff to execute if [test clause] is true
}else{
...stuff to execute if [text clause] is false
}
| example: |
if($i > 0){
print("i is positive");
}else{
print("i is negative");
}
|
|
while - Loop and execute a function, continue looping until a test clause proves false
while([test clause]){
...stuff to execute
[increment counter]
}
| example: |
$i = 0;
//loop ten times
while($i < 10){
//print number
print($i);
//increment counter
$i++;
}
|
|
for - Same as while loop, but the syntax requires that a counter increment (or some other statement) be performed each step.
for([initialization statement];[test clause];[statement for each step]){
...stuff to do
}
| example: |
//loop ten times
for($i=0;$i < 10;$i++){
//print number
print($i);
}
|
|
|
Cheatsheet
|