Game Development Community

Some questions about Strings

by beyond · in Torque Game Engine Advanced · 02/23/2011 (6:03 am) · 2 replies

Hello!

I have some questions about Strings:

1.) How to concatenate (add) two strings,
such as "strcat" function in C++?

2.) How to convert Value to String?
3.) How to convert String to Value?

#1
02/23/2011 (6:16 am)
Assuming you're talking about torque script, data types are not defined directly in torque script so you can do funky things like the following:

%bothstrings = "1" @ "a"; // concat result is "1a"
%bothstrings2 = "1" SPC "b"; // result is "1 b"

Compare strings: "str" $= "abc" ... returns false

%string = "1";
%string = %string @ "2";
(%string == 12) // returns true
(%string $= "12") // returns true

Hope that helped.
#2
02/23/2011 (12:09 pm)
Re 2) and 3): Everything is a string in TorqueScript. No conversions needed.