I have since realised I can use the replace method of the String class and done it that way. But I am interested as to why the first bit of code didn't work.
The "!=" inequality operator has higher precedence than the "=" assignment operator. See Footnote.
So, look at your first statement.
while (tmpPos = StringToStrip.indexOf("%20") != -1)
This checks to see whether StringToStrip.indexof("%20") is not equal to -1. If it is not equal to -1, tempPos is assigned the value 1. If it is equal to -1 (not not equal), tempPos is assigned the value 0.
If the result, tempPos, is zero, the while stuff will not be executed. If the result, tempPos, is not equal to zero, the while stuff will be executed. At any rate, tempPos does not have the value returned by the StringToStrip() function.
I think what you have in mind would be accomplished by
while ([glow]([/glow]tmpPos = StringToStrip.indexOf("%20")[glow])[/glow] != -1)
The parentheses around the assignment make sure the assignment is made before testing to see if the result is -1.
Better yet, maybe, get into a habit of using parentheses to make sure the intent is as clear to a human reader as it is to the compiler. I mean, the compiler never gets confused, but...