Thread: Loading a MEL
View Single Post
# 8 19-03-2003 , 12:05 PM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
A single backslash "\" in mel (and in many other programming languases) is considered as an escape character. It has a special meaning. Here are some examples

\n - means carriage return
\t - means tab

you can also use it to print special characters. an example:
Code:
print ("Maya says "hi" to all");

// Output:
// Error: Syntax error //
So how do you print quotation marks? Simple:
Code:
print ("Maya says \"hi\" to all");
Notice the backslashes before the " chars inside the string to be printed. So if the backslash plus the next character isn't a recognized "escape pattern", maya simply prints the next character as is.

This is why:
Code:
print ("C:\documents and Settings\chris\mayascripts\GIJoe.lights");

// Outputs as:
// C:documents and SettingschrismayascriptsGIJoe.lights
So to print the path with backslashes you would write:

Code:
print ("C:\\Documents and Settings\\chris\\mayascripts\\GIJoe.lights");

// Output:
// C:\Documents and Settings\chris\mayascripts\GIJoe.lights
Try what this does in the script editor:
Code:
print ("\nIt is a good habbit to start a line with a \"\\n\" because\nthe previous line didn't necessarily end with one.\n\n This line starts here with a space.\n\t\"This line is in quotation marks and starts with a tab.\"");
user added image


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!