Copy link to clipboard
Copied
How do I cause a loop to jump to the next loop item? cfbreak exits all the loop which I don't want
<cfloop condition="i LESS THAN OR EQUAL TO #ArrayLen(arrData)#">
<!--- we need to filter out problem rows so the uplaod doesn't crash'--->
<cfif not REFind("^[0-2][0-9][/][0-1][0-2][/][1-2][0-9]{3}$", arrData[1] ) > <!--- Deal date--->
jump to next loop item (ie i++)
</cfif>
thanks
<cfset i=i+1> does not cause the loop to jump to the next loop item, it mearly incraments the var i.
<cfset i=i+1> does in fact cause the loop to jump to the next item. This is inevitable, because i is your loop's index.
In any case, as others have suggested, you can ignore the i story altogether. Just follow your own instinct and code it directly as you feel it.
I want to check each row but if there is any error in any column in that row I want to ignore the entire row
<cfloop>
<cfset isRowErrorFre
...Copy link to clipboard
Copied
<cfloop condition="i LESS THAN OR EQUAL TO #ArrayLen(arrData)#">
<cfif >
<cfset i=i+1>
</cfif>
</cfloop>
Copy link to clipboard
Copied
There does not appear to be any need for a cfbreak at all.
Copy link to clipboard
Copied
why is that?
Copy link to clipboard
Copied
Because the code comments in the OP suggest that you want to process the entire array.
Copy link to clipboard
Copied
I want to check each row but if there is any error in any column in that row I want to ignore the entire row,
the code
<cfset i=i+1> does not cause the loop to jump to the next loop item, it mearly incraments the var i.
Copy link to clipboard
Copied
Read Ian's answer again.
Copy link to clipboard
Copied
<cfset i=i+1> does not cause the loop to jump to the next loop item, it mearly incraments the var i.
<cfset i=i+1> does in fact cause the loop to jump to the next item. This is inevitable, because i is your loop's index.
In any case, as others have suggested, you can ignore the i story altogether. Just follow your own instinct and code it directly as you feel it.
I want to check each row but if there is any error in any column in that row I want to ignore the entire row
<cfloop>
<cfset isRowErrorFree = true>
<!--- code to check for error in row; if error found, set isRowErrorFree = false --->
<cfif isRowErrorFree>
<!--- code to do the required calculation --->
</cfif>
</cfloop>
Copy link to clipboard
Copied
Cool, thanks guys
Copy link to clipboard
Copied
Just use your if else logic to determine what goes on in each iteration of the loop.
<cfloop ...>
<cfif this>
DO THIS
<cfelse>
DO THAT
</cfif>
</cfloop>