<pre>function replace str,oldCh,newCh,caseSens  put empty into newStr  repeat until str is empty    if caseSens = true then put caseSensOffset( oldCh, str ) into pos    else put offset( oldCh, str ) into pos    if pos <> 0 then      put char 1 to pos-1 of str after newStr      delete char 1 to pos-1 of str      delete char 1 to length(oldCh) of str      put newCh after newStr    else      put str after newStr      put empty into str    end if  end repeat  return newstrend replace</pre>