tracker issue : CF-4199031

select a category, or use search below
(searches all categories and all time range)
Title:

[ANeff] Bug for: cfloop() fails for list

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Aaron Neff / Aaron Neff ()

Created: 07/09/2017

Components: Language, CFSCRIPT

Versions: 2016,11.0,13.0

Failure Type: Non Functioning

Found In Build/Fixed In Build: 2016.0.03.00357 / 2018.0.02.313021

Priority/Frequency: Normal / Some users will encounter

Locale/System: / Win All

Vote Count: 0

cfloop() fails for list

Repro:

{code:java}
<cfscript>
  theList = "1,2,3";
  cfloop(list=theList, index="i") {
	  writeOutput(i);
  }
</cfscript>
{code}


Actual Result: Exception "Attribute validation error for the loop tag.
The tag does not have an attribute called list. The valid attribute(s) are query, startrow, endrow, file, index, item, from, to, characters, charset, group, groupcasesensitive."

Expected Result: 123 (Lucee returns expected result: https://trycf.com/gist/249b02b33bce0bcf82a7256996a5ef64/lucee5?theme=monokai)

Attachments:

Comments:

The script variant of cfloop now supports looping over list , structures , array and  query . {code:java} <cfscript> cfloop(list="1,2,3,4", index="i", item="j"){ writeoutput("index:" & i) writeoutput("item:" & j & "<br/>") } </cfscript> {code} {code:java} <cfscript> myArray = ["John", "Paul", "George", "Ringo"]; cfloop( array="#myArray#", index="idx"){ writeoutput(#idx# & "<br/>"); } </cfscript> {code} {code:java} <cfscript> Team = ["Marketing" = "John", "Sales" : ["Executive" : "Tom", "Assistant" = "Mike"],"IT":["Developers":["Dev1":"Ashley","Dev2"="Jason"]]]; cfloop( collection="#Team#" ,item="key" ){ writeoutput(#Key# & ":"); writeoutput(#SerializeJSon(Team[key])#); writeoutput("<br/>"); } </cfscript> {code} {code:java}   <cfscript> myQuery = queryNew("id,name,amount","Integer,Varchar,Integer", [ {id=1,name="One",amount=15}, {id=2,name="Two",amount=18}, {id=3,name="Three",amount=32}, {id=4,name="Four",amount=37}, {id=5,name="Five",amount=79}, {id=6,name="Six",amount=26} ]); Start = 3; End = 6; cfloop( query = "myQuery", startRow = "#Start#", endRow = "#End#"){ writeoutput("#name# #amount#" & "<br>"); } </cfscript> {code}
Comment by Suchika S.
30127 | January 17, 2019 06:46:57 AM GMT
Hi Suchika, Awesome, thank you very much! -Aaron
Comment by Aaron N.
30130 | January 18, 2019 07:40:35 AM GMT