Value > Basic Data Values > String Values |
The String class defines the characteristics of character strings. The character strings can be of any length.
See String Literals for a description of String literals.
Converts any value into its string representation.
The number of characters in the string.
Returns a new string that is the concatenation of two strings.
<string> == <string> <string> != <string> <string> > <string> <string> < <string> <string> >= <string> <string> <= <string>
Standard lexical string comparisons (case sensitive).
To perform a case insensitive equality comparison, please use the stricmp() method that performs a lower-case comparison.
Returns the indexed character as a single-character string, index starts at 1.
Sets the indexed character to the given character.
Converts the string to an instance of the given class. You can convert a string into a Name value using the as operator.
You can also convert strings to numbers using the as operator.
You can use any of the Number classes as a target class: Number, Float, or Integer. If you use Number, the appropriate class will be used depending on the syntax of the number in the string.
You can convert a string to a StringStream value using the as operator.
Converting a string to a StringStream value allows you to read through a string using the MAXScript's text file I/O operations. See StringStream Values for a description of StringStreams.
Creates a new copy of the string value and returns it.
The new value contains a copy of the text contents of the copied string and is independent of the copied string.
Frees the memory used by the string value without waiting for garbage collection.
Available in 3ds Max 9 and higher.
Compiles and evaluates the contents of the string as a MAXScript expression and returns the result of the evaluation.
The result of an execute() call is the result of the last expression in the string argument.
You can use execute() to access object using a computed name.
It retrieves the child of $foo named in the variable child_name .
Here is a more complex example:
The scope of variables used in the evaluated string is global and not the scope in effect when the execute() method is executed. So, if you call execute() within a function, scripted utility, or anywhere where the scope is not global, you will need to explicitly specify the scope of any variables used in the string that is executed. In the following example, the scope of variable posObj is local to utility myUtil , so the string needs to specify the variable’s name as being in myUtil ’s scope:
In general, you cannot access locals from outside of an object, except for top-level locals in rollouts, utilities, tools, and plug-ins (because they are semi-permanent and are stored with these objects). Function parameters and locals are dynamic and stack-based and not accessible as properties of the function definition.
For more information on variable scope, see Scope of Variables and Accessing Locals and Other Items in a Rollout from External Code.
Returns a Point2 value containing the size of the string in pixels if it was displayed in a command panel.
Returns the index of search_string in string or undefined if not found.
Parses string based on token_string and returns an array of strings. The filterString splits the input string into substrings based on the characters given in token_string , and returns each substring as a member of the array. The token_string is simply a list of 'splitter characters' (when the string is scanned, any occurrence of any of the tokens is regarded as the start of a substring). This function is useful for file import/export scripts or for any type of manual parsing.
If splitEmptyTokens is false or not specified, sequential tokens are handled as a single token and tokens at the beginning or end of the string are ignored. If splitEmptyTokens is true , each token found will result in string element in the output, with the string element in the cases ignored above being empty strings. Available in 3ds Max 8 and higher.
Returns a new string where the substring in string starting at index from_integer and of length length_integer is replaced with the new_string.new_string of any length. The sum of from_integer and length_integer must be less than the length of string .
Returns a new string consisting of the substring in string starting at index from_integer and of length length_integer . If the sum of from_integer and length_integer is greater than the length of string , a shorter string is returned containing as many characters as are available in the source. If a negative value is specified for length_integer , the remainder of the string starting from from_integer is returned.
Returns true if string is matched by the wild card pattern_string , false otherwise. The comparison is case-insensitive unless ignoreCase:false is specified.
Appends string2 to string1 . Operates on string1 in place and returns string1 as its result.
Append is typically used when incrementally building a large string from many small strings. As the string is operated on in place, memory usage might be significantly reduced because intermediate string values will not remain in memory until the next garbage collection.
In 3ds Max6 and higher, this method performs a lower case comparison of string1 and string2.
Returns an integer value < 0 if string1 is less than string 2, = 0 if string1 is identical to string 2, and > 1 if string1 is greater than string 2.
Returns a new string value with the string converted to upper case. Available in 3ds Max 2008 and higher. Previously, available in the Avguard Extensions.
Returns a new string value with the string converted to lower case. Available in 3ds Max 2008 and higher. Previously, available in the Avguard Extensions.
Returns a new string with all occurrences of <from_string> in <source_string> replaced with <to_string>. Available in 3ds Max 2008 and higher. Previously, available in the Avguard Extensions.
Returns a new string where line feeds in input string are replaced with carriage return/line feed, unless the character preceding the line feed is a carriage return. Available in 3ds Max 2008 and higher. Previously, available in the Avguard Extensions.
Returns a new string where carriage return/line feeds in input string are replaced with line feeds. Available in 3ds Max 2008 and higher. Previously, available in the Avguard Extensions.
The following script shows the use of various literals, constructors, properties, operators, and methods of the String class.