That loop can easily be implemented in script and has way too specific a use to see it being useful to many other people. I mean, how many times are you really going to check multiple variables against each other?
The answer is: not many, if you use a better method (the one suggested by starbucks)