String commands are useful for manipulation of string variables, which are variables who's values include text. Torque by default makes all variables strings, so you don't have to worry about them not working for a variable.
The string functions and their use are as follows:
strChr(string, character)
- This function takes an input string (string) and checks to see if a character (character) is contained in that string. If so, it returns the string, otherwise, it returns nothing.
strCmp(stringone, stringtwo) / striCmp
- This function compares two strings, checking to see if the input string (stringone) starts with or is equal to the second string (stringtwo). If it is the same string, it returns 0. If it starts with that, it returns 1. If it doesn't start with that, it returns -1. striCmp is case insensitive.
strPos(stringone, stringtwo) / striPos
- This function checks to see if stringtwo is located in stringone, and returns its position in the word if it is. For example, if you were checking to see if "triple" was part of my name (TripleNickels) and you used strPos, you would use strPos("TripleNickels","triple"). This would return false, since strPos is case sensitive and striPos is not.
strLen(string)
- This function gives you the length of a string in characters. "a" is one one, "abc" is three long, etc.
strLwr(string)
- This string makes whatever you input all lowercase.
strReplace(stringone, stringtwo, stringthree)
- This string replaces any instances of stringtwo in stringone with stringthree. For example, if you wanted to turn the word "stuff" into ****, you could use strReplace("I feel like a pile of stuff","stuff","****") and it would replace stuff with ****.
strStr(string)
- Does the same as strPos.
strUpr(string)
- Makes your input all uppercase
getSubStr(string, start, count)
- Gets all characters from the start point until count is up. If I wanted to get the first 5 characters of "How is your day?" I could run getSubStr("How is your day?",0,5)
getCharCount(string, char)
- Counts all the characters in the string, for example getCharCount("Crazy Cathy eats Cake at Church","C") returns c. Case sensitive.
stripChars(stringone, stringtwo)
- Removes stringtwo from stringone, for example stripChars("I hate catfish.","cat") returns "I hate fish."
lTrim(string)
- Removes spaces from the beginning of the string. Changes " hey" to "hey".
rTrim(string)
- Removes spaces from the end of the string. Changes "hey " to "hey"
trim(string)
- Does both lTrim and rTrim. Removes spaces from both side, making " hey " "hey" or doing lTrim or rTrims job.
These are all the string commands listed from console, if you feel I missed any I will add them to the list.