Game Development Community

String Functions

by Jookia · in Torque Game Engine · 12/18/2007 (6:35 am) · 13 replies

Can somebody give me a list of string functiosn to manipulate strings and their usage and the syntax?

#1
12/18/2007 (6:43 am)
Buy a Torque book
#2
12/18/2007 (6:49 am)
I've heard that the public now has access to the TDN.

If that is the case than this is exactly what you are looking for:
tdn.garagegames.com/wiki/TorqueScript_Console_Functions_3

If you can't access that then I'd probably suggest the same as Anthony.
#3
12/18/2007 (10:28 am)
dumpConsoleFunctions();

that will list all the torque functions into the console.log file. you could then copy them somewhere else.

also,

dumpConsoleClasses();

will list all the script objects, fields, and methods.

this is probably better than getting a book which could've been written using a different veresion of the engine.
#4
12/18/2007 (2:40 pm)
I use The Game Programmers Guide to Torque book because the string methods are grouped appropriately in tables:

Words,
Tokens,
Records,
Fields,
upper/lower Conversion,
Searching and Replacing,
Comparisons, and
Trimming and stripping.

It makes it very fast to find what I need (with a bookmark), and also maybe a hint if what I was specifically looking for wasn't quite optimum for what I was thinking of using it for.
#5
12/18/2007 (3:02 pm)
Jaroslav Kurcik put together a searchable compiled windows help file which docs this sort of stuff very, very nicely:use the "download" link at the top of this page.
#6
05/16/2011 (8:16 pm)
This is an old post but for anyone looking for a beginners reference to strings make sure you check out: The strings reference
#7
10/26/2014 (9:37 am)
Im working with strings myself atm, and I am honestly thinking of instead of using a string variable to instead have an array of chars. It will allow for much easier manipulation of strings

ie:

$myString[0] = "H";
$myString[1] = "e";
$myString[2] = "l";
$myString[3] = "l";
$myString[4] = "o";

By doing this, string manipulation should be much easier as I can now treat myString as an array
#8
10/26/2014 (9:43 am)
Or, perhaps instead of an array, a SimSet might be even better =)
#9
10/26/2014 (9:45 am)
And I might as well link to this other post while Im at it LOL

https://www.garagegames.com/community/forums/viewthread/94547
#10
10/27/2014 (1:29 pm)
What are you trying to accomplish? The various string functions available in the engine are pretty solid - I really can't see any reason to break a word into an array of individual letters.
#11
10/27/2014 (4:39 pm)
Richard is right. I can't think of a situation where you'd want to break a string into a script array. Not only is it probably unnecessary, it bloats the StringTable (all of those $myString[] entries actually map to $myString1, $myString2, $myString3,... in the StringTable and persist until the engine restarts).
#12
10/28/2014 (6:05 am)
Also - to address at least some part of the original request, you can find most (if not all) of the string manipulation functions in engine/source/console/consoleFunctions.cpp. Just read the help blocks for the functions for instructions....

EDIT -

Sorry - TGE.... These functions are in engine/console/ConsoleFunctions.cc.
#13
10/31/2014 (6:25 am)
I also would like to point out that it would be much slower to interpret the code if you are doing a lot of string manipulation. The engine adds extra OP codes to use the [] operator on variables. OP codes add up real quick in torquescript. (Although probably still faster than calling a method :/)

Also, just use the sub string function to get individual characters of strings.