in reply to Modifying loop structure and placement
The code block following is a small part of one of J.L. Ford's scripts that I referred to in an earlier post.
Earlier post is J.L. Ford's "Challenges".