For index loops in ColdFusion that are looping over an array or list, I always put the ArrayLen() or ListLen() in the TO attribute. I always felt a little uneasy about it because I thought maybe the function was getting evaluated for each iteration of the index loop. My fear was that this was adding additional processing overhead for each iteration.
Well, I finally got my out of shape butt off the proverbial couch and actually tested what was going on:
Launch code in new window » Download code as text file »
Turns out, the loop only iterates 4 times; the attributes only get evaluated that first time. When you stop to think about it, that makes a lot of sense; it is just a string. And if you take Conditional loops into account, it makes sense that the condition="" attribute is a string, not an evaluation. That way it can do a sort of delayed evaluation on the condition.
Man, understanding the basics is so important.
Download Code Snippet ZIP File
Comments (0) | Post Comment | Ask Ben | Permalink | Print Page
Ask Ben: Javascript Replace And Multiple Lines / Line Breaks
XStandard And Debugging ColdFusion Web Services
There are no comments posted for this web log entry.