Re: Using CFLoop to Define Variables
Try putting quotes around your variable: cfset SC#x# = listElement / -- Josh - Original Message - From: Jeanmarie Richardson [EMAIL PROTECTED] To: CF-Talk cf-talk@houseoffusion.com Sent: Monday, August 11, 2008 10:23 AM Subject: Using CFLoop to Define Variables Hello -- I am not sure if I am approaching this correctly BUT I have a list of 22 possible items where only 5 can be selected. I then need to assign these five items to a list of variables - SC1, SC2, SC3, SC4, SC5. I am trying to use CFSet within a CFLOOP tag (which loops through the list) to set up these variables but it is failing. Could somone point me in the right direction? Below is the CFLoop code I have been using. cfoutput cfset x=1 cfloop list=#saList# index=listElement delimiters=' cfset SC#x# = #listElement# cfset x =x+1 /cfloop /cfoutput ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310744 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Using CFLoop to Define Variables
Thanks Josh!! Not sure why I didn't try that :-) Try putting quotes around your variable: cfset SC#x# = listElement / -- Josh ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310746 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Using CFLoop to Define Variables
Jeanmarie, Another way is like this: cfset setVariable(SCx,listElement) Or for more cfscript purists: cfscript loop here... { setVariable(SCx,listElement); } Regarding cfset SC#x# = listEelment : Since this is an 'evaluation', and I have heard that 'evaluations' cost more performance wise than using a setVariable() with a concatenated variable name, I prefer to use the first method I indicated above. However, I can't confirm this performance issue, although maybe someone else on the list has done some performance testing with 'evaluations' and can comment on that. Dave Phillips -Original Message- From: Jeanmarie Richardson [mailto:[EMAIL PROTECTED] Sent: Monday, August 11, 2008 12:32 PM To: CF-Talk Subject: Re: Using CFLoop to Define Variables Thanks Josh!! Not sure why I didn't try that :-) Try putting quotes around your variable: cfset SC#x# = listElement / -- Josh ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310751 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Using CFLoop to Define Variables
design wise, would you be better putting those in an array instead of seperate variables? ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310752 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Using CFLoop to Define Variables
Regarding cfset SC#x# = listEelment : Since this is an 'evaluation', and I have heard that 'evaluations' cost more performance wise than using a setVariable() with a concatenated variable name, I prefer to use the first method I indicated above. However, I can't confirm this performance issue, although maybe someone else on the list has done some performance testing with 'evaluations' and can comment on that. From http://www.cfquickdocs.com/?getDoc=SetVariable#SetVariable: Description This function is no longer required in well-formed ColdFusion pages. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310754 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Using CFLoop to Define Variables
From http://www.cfquickdocs.com/?getDoc=SetVariable#SetVariable: Description This function is no longer required in well-formed ColdFusion pages. Well, that's good news. So all it comes down to then is preference. Although I do second Yuliang's comment that using an array might be better design. Dave ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310757 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Using CFLoop to Define Variables
cfset variables['SC#x#'] = listElement / will also work. On Mon, Aug 11, 2008 at 1:23 PM, Jeanmarie Richardson [EMAIL PROTECTED]wrote: Hello -- I am not sure if I am approaching this correctly BUT I have a list of 22 possible items where only 5 can be selected. I then need to assign these five items to a list of variables - SC1, SC2, SC3, SC4, SC5. I am trying to use CFSet within a CFLOOP tag (which loops through the list) to set up these variables but it is failing. Could somone point me in the right direction? Below is the CFLoop code I have been using. cfoutput cfset x=1 cfloop list=#saList# index=listElement delimiters=' cfset SC#x# = #listElement# cfset x =x+1 /cfloop /cfoutput ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310762 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Using CFLoop to Define Variables
I know... six of one, but here's how I like to do it: cfset variables['SC x] = listElement On Mon, Aug 11, 2008 at 3:42 PM, Brian Kotek [EMAIL PROTECTED] wrote: cfset variables['SC#x#'] = listElement / will also work. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310765 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Using CFLoop to Define Variables
cfset variables['SC#x#'] = listElement / will also work. On Mon, Aug 11, 2008 at 1:23 PM, Jeanmarie Richardson [EMAIL PROTECTED]wrote: I always thought this was a standard way to write it. cfset variables['SC' x] = listElement / The other ways seem a little tacky. But that's just me. Will ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310766 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4