getSubStr troubles
by Wayne Eversole · in General Discussion · 07/14/2011 (1:01 pm) · 10 replies
Hello everyone.
I have info returning from my php like so
echo $players_name, "+++", $players_kills, "+++", $players_deaths, "+++", $players_score, " Verified";
witch output into torque like this.
Recaci+++10+++5+++0 Verified
Recaci+++10+++5+++0 Verified
ecaci+++10+++5+++0 Verified
caci+++10+++5+++0 Verified
Here is my getSubStr and echo's.
%posSep = strpos(%line, "+++");
if (%posSep == 0)
return;
%len = strlen(%line);
%players_name = getSubStr(%line, 0, %posSep);
%players_kills = getSubStr(%line, %posSep + 1, %len - %posSep + 1);
%players_deaths = getSubStr(%line, %posSep + 2, %len - %posSep + 2);
%players_score = getSubStr(%line, %posSep + 3, %len - %posSep + 3);
echo (%players_name);
echo (%players_kills);
echo (%players_deaths);
echo (%players_score);
What I need is to have each echo to contain its own value without the +++ and without all the other info.
Any tips?
Thanks
I have info returning from my php like so
echo $players_name, "+++", $players_kills, "+++", $players_deaths, "+++", $players_score, " Verified";
witch output into torque like this.
Recaci+++10+++5+++0 Verified
Recaci+++10+++5+++0 Verified
ecaci+++10+++5+++0 Verified
caci+++10+++5+++0 Verified
Here is my getSubStr and echo's.
%posSep = strpos(%line, "+++");
if (%posSep == 0)
return;
%len = strlen(%line);
%players_name = getSubStr(%line, 0, %posSep);
%players_kills = getSubStr(%line, %posSep + 1, %len - %posSep + 1);
%players_deaths = getSubStr(%line, %posSep + 2, %len - %posSep + 2);
%players_score = getSubStr(%line, %posSep + 3, %len - %posSep + 3);
echo (%players_name);
echo (%players_kills);
echo (%players_deaths);
echo (%players_score);
What I need is to have each echo to contain its own value without the +++ and without all the other info.
Any tips?
Thanks
About the author
#2
07/14/2011 (1:55 pm)
Would be much easier if your php returned spaces instead of "+++". With spaces you can directly use getWord().
#3
07/14/2011 (2:31 pm)
What would be the syntax to use getWord() ?
#4
You can also use TABs instead of spaces and use getField(), or NL (new line) and use getRecord().
This is good to have at hand.
07/14/2011 (2:40 pm)
// lets say // %line = "Recaci 10 5 0 Verified" %players_name = getWord(%line, 0); %players_kills = getWord(%line, 1); %players_deaths = getWord(%line, 2); %players_score = getWord(%line, 3);
You can also use TABs instead of spaces and use getField(), or NL (new line) and use getRecord().
This is good to have at hand.
#7
07/14/2011 (3:51 pm)
Glad to help.
#8
Thanks
07/14/2011 (5:08 pm)
Anything special I need to do in order to display those values in a gui?Thanks
Torque Owner Wayne Eversole
Default Studio Name
There are some screen shots on my website.
http://recaci.freezoka.net/