In your FCMP function should the computation inside the loop use +sign(n) instead of +1 ?

p = find(str,sub,sign(n)*p + sign(n) );