Sorry for my late answer, as I was on vacation.
Just in case you did not overcome yourself the error:
12820 if substr(idx(i),1,1) = 'K' and length(compress(idx(i),'K',kd) = 8
------
72
12821 then id = idx(i);
the code line should be:
if substr(idx(i),1,1) = 'K' and length(compress(idx(i)) , 'K' , kd ) = 8
then id = idx(i);
I have added a ) at the right place.
... View more