TorqueScript Reference
Functions

Functions

String getSubStr (sourceString, start, count)
 
String ltrim (sourceString)
 
String rtrim (sourceString)
 
String strchr (sourceString, char)
 
Integer strcmp (string1, string2)
 
Integer stricmp (string1, string2)
 
String stripChars (sourceString, chars)
 
String stripColorCodes (stringtoStrip)
 
String stripTrailingSpaces (string)
 
Integer strlen (string)
 
String strlwr (sourceString)
 
Integer strpos (sourceString, searchString, [offset]?)
 
String strrchr (sourceString, char)
 
String strreplace (sourceString, from, to)
 
Integer strstr (sourceString, searchString)
 
String strupr (sourceString)
 
String trim (sourceString)
 

Detailed Description

Function Documentation

◆ getSubStr()

String getSubStr ( sourceString  ,
start  ,
count   
)

Use the getSubStr function to get a sub-string of sourceString, starting at character index start and ending at character index start + count, or the end-of-string, which ever comes first. If start + count is greater than the length of sourceString, the extraction will return a string shorter than count.

Parameters
sourceStringThe string from which to extract a sub-string.
startThe character index at which the extraction starts.
countThe length of the sub-string to extract.
Returns
Returns a string made up of the character at start in sourceString and ending at the end of the original sourceString, or start + count, whichever comes first.
See also
strchr

◆ ltrim()

String ltrim ( sourceString  )

Use the ltrim function to strip the leading white space from sourceString. White space is any character in this set: spaces, TABs, and NULL strings.

Parameters
sourceStringThe string to be trimmed.
Returns
Returns sourceString with all the leading white spaces removed.
See also
stripChars, stripMLControlChars, stripTrailingSpaces, rtrim, trim

◆ rtrim()

String rtrim ( sourceString  )

Use the rtrim function to strip the trailing white space from sourceString. White space is any character in this set: spaces, TABs, and NULL strings.

Parameters
sourceStringThe string to be trimmed.
Returns
Returns sourceString with all the trailing white spaces removed.
See also
stripChars, stripMLControlChars, stripTrailingSpaces, ltrim, trim

◆ strchr()

String strchr ( sourceString  ,
char   
)

Use the strchr function to extract a sub-string of sourceString, where the sub-string is equal to the first occurence of char in sourceString followed by the remainder of sourceString.

Parameters
sourceStringThe string from which to extract a sub-string.
charThe character to search for in sourceString.
Returns
Returns a string composed of first instance of char in sourceString, and all of the characters after it. If char is not found, a NULL string is returned.
See also
getSubStr

◆ strcmp()

Integer strcmp ( string1  ,
string2   
)

Use the strcmp function to do a lexicographic case sensitive string comparison between string1 and string2.

Parameters
string1String to be compared to string2.
string2String to be compared to string1.
Returns
Returns a numeric value: <-1 (string1 is less than string2, including case), 0 (string1 is equal to string2, including case), 1 (string1 is greater than string2, including case)>.
See also
see stricmp, strstr

◆ stricmp()

Integer stricmp ( string1  ,
string2   
)

Use the stricmp function to do a lexicographic case in-sensitive string comparison between string1 and string2.

Parameters
string1String to be compared to string2.
string2String to be compared to string1.
Returns
Returns a numeric value: <-1 (string1 is less than string2, ignoring case), 0 (string1 is equal to string2, ignoring case), 1 (string1 is greater than string2, ignoring case)>.
See also
see strcmp, strstr

◆ stripChars()

String stripChars ( sourceString  ,
chars   
)

Use the stripChars function to remove chars from sourceString.

Parameters
sourceStringThe string to be modified.
charsThe character or characters to search for and remove.
Returns
Returns a copy of sourceString, from which all instances of chars have been removed. This may be the original sourceString, if chars was not found.
See also
stripMLControlChars, stripTrailingSpaces

◆ stripColorCodes()

String stripColorCodes ( stringtoStrip  )

remove TorqueML color codes from the string.

Parameters
stringtoStringThe string from which to remove TorqueML color codes
Returns
A string consisting of the original string minus color codes

◆ stripTrailingSpaces()

String stripTrailingSpaces ( string  )

Removes all spaces after the final

Parameters
stringfrom which to remove trailing spaces
Returns
the source string minus trailing spaces

◆ strlen()

Integer strlen ( string  )

Use the strlen function to determine how many characters there are in string.

Parameters
stringThe string to count characters for.
Returns
Returns the number of characters in string, or 0 if string is invalid or a NULL string

◆ strlwr()

String strlwr ( sourceString  )

Use the strlwr function to convert all alpha characters in sourceString to lower-case equivalents.

Parameters
sourceStringThe string to be modified.
Returns
Returns a copy of sourceString in which all upper-case characters have been converted to lower-case letters.
See also
strupr

◆ strpos()

Integer strpos ( sourceString  ,
searchString  ,
[offset] ?   
)

Use the strPos function to locate the first instance of searchString in sourceString, starting at character 0, or at an optional offset.

Parameters
sourceStringThe string in which to search for searchString.
searchStringThe string for which to search for in sourceString.
offsetAn optional non-negative integer value representing the character offset within sourceString at which to begin the search.
Returns
Returns a numeric character index representing the postion in sourceString at which searchString was found, or -1 to indicate that no instance of searchString was found.
See also
strstr

◆ strrchr()

String strrchr ( sourceString  ,
char   
)

strrchr searches the sourceString for the last occurance of the given char

Parameters
sourceStringThe string to search
Returns
Either a string consisting of the given string from the last occurance of the given char on or an empty string if not found

◆ strreplace()

String strreplace ( sourceString  ,
from  ,
to   
)

Use the strreplace function to replace every instance of from in sourceString with to. This function is case-sensitive and only does exact matching

Parameters
sourceStringThe string to do replacement operations on.
fromThe old value to be replaced.
toThe new value to replace old values with.
Returns
Returns a new version of sourceString in which every instance of the value in from was replaced with the value in to.

◆ strstr()

Integer strstr ( sourceString  ,
searchString   
)

Use the strstr function to locate the first instance of searchString in sourceString.

Parameters
sourceStringThe string in which to search for searchString.
searchStringThe string for which to search for in sourceString.
Returns
Returns a numeric character index representing the position in sourceString at which searchString was found, or -1 to indicate that no instance of searchString was found.
See also
strpos

◆ strupr()

String strupr ( sourceString  )

Use the strupr function to convert all alpha characters in sourceString to upper-case equivalents.

Parameters
sourceStringThe string to be modified.
Returns
Returns a copy of sourceString in which all lower-case characters have been converted to upper-case letters.
See also
strlwr

◆ trim()

String trim ( sourceString  )

Use the trim function to strip the leading and trailing white space from sourceString. White space is any character in this set: spaces, TABs, and NULL strings.

Parameters
sourceStringThe string to be trimmed.
Returns
Returns sourceString with all the leading and trailing white spaces removed.
See also
stripChars, stripMLControlChars, stripTrailingSpaces, ltrim, rtrim