In my last blog post, I included a screenshot of some code from BaseElements 2. I’m always nervous exposing my code to the outside world, as there’s a good chance that someone smarter than yourself will take a look and point out your weaknesses. Well, Daniel Wood from filemakerweetbix sent me a note to tell me I’ve been using slow looping methods in that code.

Basically I’m taking the list of variables and working through them one at a time. Each time I process the first one in the list, and then chop the list by doing a RightValues ( list, listlength -1 ). It’s not the fastest method of looping and Daniel has a very good explanation of why and the various alternatives in a post on his blog, Thinking Outside the Loop. Well worth reading if you’re interested in optimisations.

Looking back at my old code, I’m not sure what the reason for that looping style was, that particular bit of code was written about 2 years ago, and rarely touched since. I guess that means we should all publicise our code more often, and hope more smart people take an interest.