Re: Looping through arrays with structures
Thanks all. That was very helpful. Here's the code I ended up using. cfloop from=1 to=#arrayLen(keyword_results)# index=x cfloop from=1 to=#arrayLen(keyword_results[x].images)# index=y cfoutput#keyword_results[x].images[y]#/cfoutput /cfloop /cfloop ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:337280 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Looping through arrays with structures
I thought images was a structure containing an array? On Tue, Sep 21, 2010 at 5:15 PM, Richard Steele r...@photoeye.com wrote: Thanks all. That was very helpful. Here's the code I ended up using. cfloop from=1 to=#arrayLen(keyword_results)# index=x cfloop from=1 to=#arrayLen(keyword_results[x].images)# index=y cfoutput#keyword_results[x].images[y]#/cfoutput /cfloop /cfloop ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:337289 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Looping through arrays with structures
No worries. An honest mistake. I've actually never used the Array attribute since I've been looping this way for 10 years. And unless it's inherently faster (which I doubt) I suspect I never will. I actually prefer my loops to use an int as the index. That was I've always got an easily available currentrow-like variable. On Fri, Sep 17, 2010 at 11:25 PM, Andrew Scott andr...@andyscott.id.auwrote: Hehe, I doubt you are blind at all. I swear I actually read it as using the Array attribute, oh well let me get my eyes checked. Regards, Andrew Scott http://www.andyscott.id.au/ -Original Message- From: Jacob Munson [mailto:yacoub...@gmail.com] Sent: Saturday, 18 September 2010 12:54 PM To: cf-talk Subject: Re: Looping through arrays with structures Am I blind? The email I read from Michael does NOT show the array attribute. In fact, his loop looks exactly like your code. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:337208 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Looping through arrays with structures
cfloop from=1 to=#arrayLen(firstArray)# index=x cfloop from=1 to=#arrayLen(firstArray[x].images.secondArray)# index=y cfoutput#firstArray[x].images.secondArray[y]#/cfoutput /cfloop /cfloop On Fri, Sep 17, 2010 at 8:18 PM, Richard Steele r...@photoeye.com wrote: I have an array with a structure that has an array. How do I loop through this in CF8 and retrieve the second array's 5 digit numbers? Thanks in advance. array 1 | | struct | IMAGES | | | array | | 1 | 18990 | | 2 | 8 | | 3 | 39209 | | ID | 13763 ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:337199 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Looping through arrays with structures
That won't work in certain versions of ColdFusion, if you are not using the version of ColdFusion that supports this. You can do a normal cfloop from and to and use the indexing of the array in this manner cfloop from=1 to=#ArratLen(myArray)# index=arrayCounter myArray[arrayCounter].images /cfloop Regards, Andrew Scott http://www.andyscott.id.au/ -Original Message- From: Michael Grant [mailto:mgr...@modus.bz] Sent: Saturday, 18 September 2010 10:35 AM To: cf-talk Subject: Re: Looping through arrays with structures cfloop from=1 to=#arrayLen(firstArray)# index=x cfloop from=1 to=#arrayLen(firstArray[x].images.secondArray)# index=y cfoutput#firstArray[x].images.secondArray[y]#/cfoutput /cfloop /cfloop ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:337200 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Looping through arrays with structures
What version of cf won't my code work in? On Fri, Sep 17, 2010 at 8:42 PM, Andrew Scott andr...@andyscott.id.auwrote: That won't work in certain versions of ColdFusion, if you are not using the version of ColdFusion that supports this. You can do a normal cfloop from and to and use the indexing of the array in this manner cfloop from=1 to=#ArratLen(myArray)# index=arrayCounter myArray[arrayCounter].images /cfloop Regards, Andrew Scott http://www.andyscott.id.au/ -Original Message- From: Michael Grant [mailto:mgr...@modus.bz] Sent: Saturday, 18 September 2010 10:35 AM To: cf-talk Subject: Re: Looping through arrays with structures cfloop from=1 to=#arrayLen(firstArray)# index=x cfloop from=1 to=#arrayLen(firstArray[x].images.secondArray)# index=y cfoutput#firstArray[x].images.secondArray[y]#/cfoutput /cfloop /cfloop ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:337201 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Looping through arrays with structures
You can't be serious asking that sort of question, the array Attribute was introduced in ColdFusion 8. So that means people who are still running ColdFusion 5 - 7 will not be able to use that code. Regards, Andrew Scott http://www.andyscott.id.au/ -Original Message- From: Michael Grant [mailto:mgr...@modus.bz] Sent: Saturday, 18 September 2010 11:09 AM To: cf-talk Subject: Re: Looping through arrays with structures What version of cf won't my code work in? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:337203 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Looping through arrays with structures
Am I blind? The email I read from Michael does NOT show the array attribute. In fact, his loop looks exactly like your code. On Fri, Sep 17, 2010 at 6:42 PM, Andrew Scott andr...@andyscott.id.auwrote: That won't work in certain versions of ColdFusion, if you are not using the version of ColdFusion that supports this. You can do a normal cfloop from and to and use the indexing of the array in this manner cfloop from=1 to=#ArratLen(myArray)# index=arrayCounter myArray[arrayCounter].images /cfloop Regards, Andrew Scott http://www.andyscott.id.au/ -Original Message- From: Michael Grant [mailto:mgr...@modus.bz] Sent: Saturday, 18 September 2010 10:35 AM To: cf-talk Subject: Re: Looping through arrays with structures cfloop from=1 to=#arrayLen(firstArray)# index=x cfloop from=1 to=#arrayLen(firstArray[x].images.secondArray)# index=y cfoutput#firstArray[x].images.secondArray[y]#/cfoutput /cfloop /cfloop ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:337204 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Looping through arrays with structures
He didn't use the array attribute. He used the exact same index loop that you did (from=1 to=#arrayLen(myArray)#). On Fri, Sep 17, 2010 at 6:56 PM, Andrew Scott andr...@andyscott.id.auwrote: You can't be serious asking that sort of question, the array Attribute was introduced in ColdFusion 8. So that means people who are still running ColdFusion 5 - 7 will not be able to use that code. Regards, Andrew Scott http://www.andyscott.id.au/ -Original Message- From: Michael Grant [mailto:mgr...@modus.bz] Sent: Saturday, 18 September 2010 11:09 AM To: cf-talk Subject: Re: Looping through arrays with structures What version of cf won't my code work in? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:337205 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Looping through arrays with structures
Hehe, I doubt you are blind at all. I swear I actually read it as using the Array attribute, oh well let me get my eyes checked. Regards, Andrew Scott http://www.andyscott.id.au/ -Original Message- From: Jacob Munson [mailto:yacoub...@gmail.com] Sent: Saturday, 18 September 2010 12:54 PM To: cf-talk Subject: Re: Looping through arrays with structures Am I blind? The email I read from Michael does NOT show the array attribute. In fact, his loop looks exactly like your code. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:337206 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm