String Manipulation
by Deozaan · in Torque Game Builder · 12/22/2008 (2:07 pm) · 2 replies
I've searched for an answer to this but I can only find information on manipulating entire words at a time. What I'm looking for is a way to take a single word and look at each character individually.
For example, for the string "bobby3" I would want to be able to read every character one at a time, in order, and do something with it.
My actual intention is to use numbers. Since, as I recall, the way that TorqueScript works is to make everything as a string anyway, I want to use numbers with leading zeros (i.e. "000321") then read each number, in order, one at a time, and do something with those numbers.
So what's the best way to do that?
Thanks in advance!
For example, for the string "bobby3" I would want to be able to read every character one at a time, in order, and do something with it.
My actual intention is to use numbers. Since, as I recall, the way that TorqueScript works is to make everything as a string anyway, I want to use numbers with leading zeros (i.e. "000321") then read each number, in order, one at a time, and do something with those numbers.
So what's the best way to do that?
Thanks in advance!
Associate Phillip O'Shea
Violent Tulip
%myWord = "000321"; %characterCount = strlen(%myWord); for (%i = 0; %i < %characterCount; %i++) { %myChar = getSubStr(%myWord, %i, 1); ... }That should do it.