String Literals

String literals in MAXScript are one or more characters enclosed in double quotes:

"3ds Max"

"October 5th, 1996"

String literals can contain any character except another plain double quote. You can include a double quote in a string literal, as well as some useful control characters, by using a "\" (backslash) escape character sequence. The valid escape sequences are:

\" -- a double quote character

\n -- a newline character

\r -- a carriage return character

\t -- a TAB character

\* -- an asterisk character

\? -- a question mark character

\\ -- a single "\" character

\% -- a percent character

\x{d} -- a hexadecimal character


print "foo should be quoted like this: \"foo\" and a new line: \n"

would output:

"foo should be quoted like this: "foo" and a new line:


A "\" character that does not preface one of the specified characters is left as a single backslash.

You can break a string literal into several lines and the line breaks will stay in the string. For example:

"Twas brillig and the slithy tobes

did gyre and gimbol in the wabe

or something like that..."

Non-Printing Characters in Strings

You can specify non-printing characters in string literals using the \x hexadecimal escape sequence convention from C/C++. The form is:

\x{<hex_digit>}+ -- <hex_digit> is a hexadecimal digit (0-9,a-f)


str = "Copyright \xa9 1997, FrabWorks, Inc"

would insert a copyright sign ©. Hexadecimal a9 is the code for that symbol.

Running the following script displays in Listener the characters associated with each hexadecimal code:



for i=1 to char.count do

for j=1 to char.count do



format "%% %\n" char[i] char[j] s


File Path Name Strings

File path name strings use the backslash character to separate a parent directory from its sub-directory. The backslash is used as an escape character, therefore file path names specified in a string should use the escape character sequence for a single "\" character, i.e., "\\".

An example is:

scene_path = "g:\\3dsmax25\\scenes" -- specifies file path g:\3dsmax25\scenes

For strings that are used as file names or paths, the "/" character can be used instead of the "\\". MAXScript internally interprets the "/" character as a "\" character when used in a file path name string.

An example is:

scene_path = "g:/3dsmax25/scenes" -- specifies file path g:\3dsmax25\scenes

See also

String Values