PDA

View Full Version : string



kensapp
April 25th, 2005, 10:21 AM
I tried to write a function that will strip the carriage return off of strings in a text file... it works fins inside the function, but the changed string is not passed back out... I know I must be missing something very simple.. can anyone help?

trace commands show that the word is being stripped of the extra characters inside the function, but after the function is called the changed string is not passed back out because the length is back to the original size again

function stripit (word) { //Strip off the \r\n from a string
if ((word.indexOf ("\r\n")) ne -1) { //if the carriage return is found
trace (word);
trace (word.length);
word = word.substring (0, (word.indexOf ("\r\n"))); //strip off the part up until the \r\n
trace (word);
trace (word.length);
}
}

temp="Verbs\r\n";
stripit (temp);
trace (temp.length);

foodpk
April 25th, 2005, 10:33 AM
Try adding
return word;
to the end of the function.