darren, I quess it was that iif-stuff.

it does not always work the same way one would think.

anyway, could you try your current code with changing of:
code:
if (ascan($1,$n)>-1 and $m) or (ascan($1,$n)=-1 and 0=$m) $=$+chr(1)+$n endif

to:
code:
if ascan($1,$n)+$m<>0 $=$+chr(1)+$n endif

_________________________
!

download KiXnet