String handling in .cs files
by Mark Brown · in Torque Game Engine · 10/29/2006 (11:39 am) · 3 replies
Are there any basic string handing calls in .cs script files. I can build on them to do what I want, but I can't seem to find even the most simple ones.
For example:
%MyString = "airplane";
What is the fourth letter in the string %MyString? What is its length?
For questions like "are there any spaces?" I could write a function if I had the first two tools above.
Any thoughts?
For example:
%MyString = "airplane";
What is the fourth letter in the string %MyString? What is its length?
For questions like "are there any spaces?" I could write a function if I had the first two tools above.
Any thoughts?
About the author
Associate William Lee Sims
Machine Code Games
ConsoleFunction(strcmp, S32, 3, 3, "(string one, string two)" "Case sensitive string compare.") ConsoleFunction(stricmp, S32, 3, 3, "(string one, string two)" "Case insensitive string compare.") ConsoleFunction(strlen, S32, 2, 2, "(string str)" "Calculate the length of a string in characters.") ConsoleFunction(strstr, S32 , 3, 3, "(string one, string two) " "Returns the start of the sub string two in one or" " -1 if not found.") ConsoleFunction(strpos, S32, 3, 4, "(string hay, string needle, int offset=0) " "Find needle in hay, starting offset bytes in.") ConsoleFunction(ltrim, const char *,2,2,"(string value)") ConsoleFunction(rtrim, const char *,2,2,"(string value)") ConsoleFunction(trim, const char *,2,2,"(string)") ConsoleFunction(stripChars, const char*, 3, 3, "(string value, string chars) " "Remove all the characters in chars from value." ) ConsoleFunction(stripColorCodes, const char*, 2,2, "(stringtoStrip) - " "remove TorqueML color codes from the string.") ConsoleFunction(strlwr,const char *,2,2,"(string) " "Convert string to lower case.") ConsoleFunction(strupr,const char *,2,2,"(string) " "Convert string to upper case.") ConsoleFunction(strchr,const char *,3,3,"(string,char)") ConsoleFunction(strreplace, const char *, 4, 4, "(string source, string from, string to)") ConsoleFunction(getSubStr, const char *, 4, 4, "getSubStr(string str, int start, int numChars) " "Returns the substring of str, starting at start, and continuing " "to either the end of the string, or numChars characters, whichever " "comes first.") ConsoleFunction( stripTrailingSpaces, const char*, 2, 2, "stripTrailingSpaces( string )" )