The code along with the two subroutines have been uploaded in one text file.
The two subroutines should be saved as individual clips so you will end up with THREE new clips.
I have my subroutines in a different library but changed the code so you should put the subs in the same library as the calling program. Easily changed, if you wish. (Change ^!Clip to ^!FarClip and add the library name)
I'm sure it was a mistake for me to notice I didn't code the program to return a Return Code for use when using as a subroutine as I frequently do. This means you can check the code after it is called each time to make sure it didn't find a problem. That required some minor code changes which I think I made correctly but I've learned there are NO safe code changes. When new to a language, I crashed a production system by making ONE itty, bitty, innocent, temporary change to ONE line. My friend who was on call that night was phoning me at 3 AM while I SWORE my change couldn't have been the cause. I learned several things that night...
Let me know if you find any bugs.