Game Development Community

How to get access to chars in string variable (Torque Script)?

by beyond · in Torque Game Engine Advanced · 02/17/2011 (5:43 am) · 1 replies

Hello!

I need to get access to chars in string variable.
C++ syntax such as is not working:

%my_str = "TestString";
%my_str[5] = %my_str[6]; // not work!
%my_str[1] = 'a'; // not work!
echo (%my_str);

How I can to get separate chars of string?

Thanks.

#1
02/17/2011 (6:37 am)
The solution:
getSubStr(string str, int start, int numChars)

You can't assume each character takes up one byte in C/C++ either.