Mel: String

From wikinotes
Revision as of 16:07, 6 October 2014 by Will (talk | contribs) (Created page with "= New Line = <blockquote> <pre> print "\n"; //Begins a New Line print "a \n b"; //Prints "a" then a new line starting with "b" print "a", "b"; //Prints "a" then...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

New Line

print "\n";					//Begins a New Line

print "a \n b";					//Prints "a" then a new line starting with "b"

print "a", "b";					//Prints "a" then a new line starting with "b"

Adding to a string

string $test = "String";
print ($test +"Cheese");			//Prints "String Cheese"

Testing if a string holds a value

if ($string == "") { //then execute }}		//Test for an Empty string

Tokenize

Tokenize will divide a string by a single character and store it's chunks in an array. Tokenize with multiple characters will search for any individual instance of a character. ex: tokenize $mystring "ab" $buffer; would remove any "a"s or "b"s and not search for "ab"s.

string $mystring = "myObject.translateX.89";
string $buffer[];

tokenize $mystring "." $buffer;


//Result://

buffer[0] == "myyObject";
buffer[1] == "translateX";
buffer[2] == "89";

substituteAllString

substituteAllString replaces every instance of a string with another string. You can use multiple characters.

string $origString = "C:/Users/Will/Desktop"

substituteAllString ($origString, "/", "_")

//Result:// C:_Users_Will_Desktop