How to get a character at a specific index of a String? [solved]
by Max Kielland · in Torque Game Builder · 01/18/2013 (6:01 am) · 2 replies
Hi,
In C/C++ we can treat char* as string arrays and extract a single character by the array operator [].
In Torque Scripting there is no specific string type so the use of [] would treat the variable as an array name instead of extracting the character.
How can I write the C/C++ equal in Torque script to where MyChar would result in 'W'?
I guess I can do
In C/C++ we can treat char* as string arrays and extract a single character by the array operator [].
In Torque Scripting there is no specific string type so the use of [] would treat the variable as an array name instead of extracting the character.
How can I write the C/C++ equal in Torque script to where MyChar would result in 'W'?
char *MyString = "Hello World"; char MyChar = MyString[6];
I guess I can do
%MyString = "Hello World"; %MyChar = getSubStr(%MyString,6,1);but is seems a little bit overkill to just get one character. What is the intended way of doing this?
About the author
Owner of MK Development www.mkdevelopment.se
#2
Are you alone answering all questions here?
You have been very helpful, thank you.
01/18/2013 (6:51 am)
Okay, thank you.Are you alone answering all questions here?
You have been very helpful, thank you.
Torque Owner Richard Ranft
Roostertail Games