Replace acharacter with space
by Nir Ziso · in Torque Game Builder · 08/02/2006 (10:06 am) · 5 replies
Hoe can i use the strreplace function to replace agiven string with space
how can i pass the function space character i did this but it is not working
function mystr::read_string(%this,%str,%delimiter)
{
echo("_______________________________________________");
echo("str="SPC %str);
echo("delimiter="SPC %delimiter);
%temp=strreplace(%str, %delimiter,SPC );
echo("new string="SPC %temp);
}
how can i pass the function space character i did this but it is not working
function mystr::read_string(%this,%str,%delimiter)
{
echo("_______________________________________________");
echo("str="SPC %str);
echo("delimiter="SPC %delimiter);
%temp=strreplace(%str, %delimiter,SPC );
echo("new string="SPC %temp);
}
#2
SPC is just an operator that concatenates 2 strings.
08/02/2006 (11:25 am)
Use a string that only consists of a space: " "SPC is just an operator that concatenates 2 strings.
#3
function mystr::read_string(%this,%str,%delimiter)
{
%wrapper = new ScriptObject();
echo("_______________________________________________");
echo("str="SPC %str);
echo("delimiter="SPC %delimiter);
%k=" ";
%temp=strreplace(%str, %delimiter,%k);
echo("new string with space="SPC %temp);
echo("string length with spaces="SPC strlen(%temp)) ;
echo("number of spaces"SPC getWordCount(%temp));
%counter=getWordCount(%temp);
for(%i=0;%i<%counter;%i++)
{
%msg=getWord(%temp,%i);
echo("msg="SPC %msg);
%wrapper.contents[%i]=%msg;
}
for(%i=0;%i<%counter;%i++)
echo("this is the array"SPC %wrapper.contents[%i]);
}
08/02/2006 (11:58 am)
Thanks alot i found it and here is my code to read asring with delimiter and put the values on an arrayfunction mystr::read_string(%this,%str,%delimiter)
{
%wrapper = new ScriptObject();
echo("_______________________________________________");
echo("str="SPC %str);
echo("delimiter="SPC %delimiter);
%k=" ";
%temp=strreplace(%str, %delimiter,%k);
echo("new string with space="SPC %temp);
echo("string length with spaces="SPC strlen(%temp)) ;
echo("number of spaces"SPC getWordCount(%temp));
%counter=getWordCount(%temp);
for(%i=0;%i<%counter;%i++)
{
%msg=getWord(%temp,%i);
echo("msg="SPC %msg);
%wrapper.contents[%i]=%msg;
}
for(%i=0;%i<%counter;%i++)
echo("this is the array"SPC %wrapper.contents[%i]);
}
#5
08/03/2006 (4:43 am)
Thanks
Torque 3D Owner Eric Armstrong
Bloody Tongue Games
{
echo("_______________________________________________");
echo("str="SPC %str);
echo("delimiter="SPC %delimiter);
%temp=strreplace(%str, %delimiter, " ");
echo("new string="SPC %temp);
}
That should work I think, but I haven't tested it...