The cats were around again and I figured it was time to skin one a different way was all...
No right or wrong, simply different. Mart's way clearly illustrates the logic and requires but a "use first 8 chars or all chars if <8" comment to be understood by anyone. My "golfed" example should have a few more comments if used in production to make sure the process is clear.
I comment my code heavily because I often can't remember why I coded something a certain way 3 hours after I coded it. I actually scanned several of my production code projects a while back with a modified version of Sanity and found that my Comment to Code ratio was 1.6:1 D)
Glenn
PS - Golf tournaments are great ways to learn.. and several have found their way (through adaptation) into production scripts, such as the LuhnMod and MOAN network subnet UDFs.
_________________________
Actually I
am a Rocket Scientist!