The error is due to your 'setq' call... bear in mind that 'setq' will return the last value bounded - think about the implications of this when using the WHILE statement.
You know, it really cracks me up when I see answers like this.
Not your answer, but my fault. You see, I have other code that is formatted identically, and it works without a hitch. I get the same thing with code that uses more than two levels deep with CAR or CDR. For some reason (and it's just my luck), I cannot get code to work with CADDR or CADR or anything more than three characters, it always errors out on me. I can borrow someone elses code from theSwamp, and I have to change it in order to get it to work for me. I've just learned to accept it as 'my luck'. It sits there next to Murphy's Law, the two are twins. When something occurs outside of Murphy's Law, it's Hangman's Luck. One does not trump the other, it just coincides in an opposite universe.
When I'm driving down the street, I usually get stopped at EVERY red light along my street I am travelling. Others I know can go for miles before being stopped. But when I ride shotgun in their car, it never fails, THEY get stopped at EVERY red light along the street. No explanation & Murphy's law doesn't compute. So it's Hangman's Luck.
Maybe I should change my username.
As for my point - think about how a COND statement evaluates when it reaches a test expression that returns true.
"%%129OPENPORT%%130"
Ahh, good point indeed. When COND runs, it runs only once to complete it's task, then goes back to the beginning of the loop. So if two fractions are in the same string, the second is then ignored and lost because the count then increases. Ahh Nuts!
...
So, off the top of my head, I'm thinking after the first search of all text and an initial cleanup, do a second search of all text. But what if there are three fractions in the same line of text ?? So that idea isn't going to work well.
There has to be a way to search the same string of text for more than one occurance of a fraction.
...
I've got some thinking to do.