Echo
by Robert Stewart · in Torque Game Engine · 10/24/2004 (5:19 pm) · 6 replies
I am trying to do a echo in torque script, in a way so that it will goto to character, here is an example
"%line = "12345";"
I only want to echo the 5th character, is this possible? thanks.
"%line = "12345";"
I only want to echo the 5th character, is this possible? thanks.
About the author
#2
getWord(%blah, 0)
thanks
10/24/2004 (8:09 pm)
That is helpfull, but i think i might have found a better way, i found this accidentily getWord(%blah, 0)
thanks
#3
%mystring = "Hello World!";
getWord(%mystring,0); // "Hello"
getWord(%mystring,1); // "World!"
10/24/2004 (8:11 pm)
That would return 12345.... words are seperated by spaces, so if you had:%mystring = "Hello World!";
getWord(%mystring,0); // "Hello"
getWord(%mystring,1); // "World!"
#4
10/25/2004 (7:40 am)
Yes that is more to what i was looking for, sorry for confusion, thanks everyone.
#5
10/25/2004 (7:48 am)
You could also use "getSubStr(string str, int start, int numChars)"
#6
10/25/2004 (8:37 am)
That would also work, ill have to try them to see wich one works better with my design, thanks guys.
Associate Chris Haigler
Jester Dance
function getLastChar(%line) { %lastChar = getSubStr(%line, strlen(%line)-1, strlen(%line)); return %lastChar; }As an example, echo(getLastChar("12345")); would return '5'. Hope this helps.