Is it necessary to var scope loop variables in CFScript?
- by Mel
When using CFML and CF9 I usually var scope my loop variables; in this case local.i, for example:
<cfloop list="#this.list#" index="local.i">
<cfif Len(local.i) GT 10>
// do something
</cfif>
</cfloop>
I recently started converting some stuff into CFScript, and (to my disappointment I found out that there is no way to loop over a list in CFScript) I'm wondering if I should still var scope my loop variables, and how:
for (i = 1; LTE ListLen(this.list); i = i + 1 ) {
if (Len(ListGetAt(this.list, i) GT 10)) {
// do something
}
}
Should I be doing local.i = 1 and local.i = local.i + 1 istead of the sample code in my example? Is it necessary?
EDIT: I should also ask if the CFScript form of my CFML loop is correct; I ask because I just noticed that my CFML loop uses a , (comma and space) for the delimiter argument, which seems non-existence in the CFScript version of the loop.