|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
i have the following setup
<cfset dp1 = "0,21600,4"> <cfset dp2 = "21600,32400,2"> <cfset dp3 = "32400,43200,2"> <cfset dp4 = "43200,57600,2"> <cfset dp5 = "57600,68400,1"> <cfset dp6 = "68400,72000,1"> <cfset dp7 = "72000,79200,1"> <cfset dp8 = "79200,86400,1"> i am trying to implement the following loop and reach the values of each list above, <cfloop from="1" to="8" step="1" index="inx"> <cfset crap = 'dp'&inx> <cfoutput>#crap#</cfoutput><cfoutput>#dp1#</cfoutput> the output of this code is dp1 0,21600,4 how can i make crap reference to dp1 object so it will get the values for dp1? thanks for the help in advance |
|
#2
|
||||
|
||||
|
<cfset crap = 'dp'&inx>
is interpreted as a string Use this: <cfset crap = Evaluate("dp" & inx)> |
|
#3
|
|||
|
|||
|
thanks bocmaxima
|
|
#4
|
|||
|
|||
|
A better way would be to start with an array:
<cfset dp = arrayNew(1)> <cfset dp[1] = "0,21600,4"> <cfset dp[2] = "21600,32400,2"> And then loop over the array: <cfoutput> <cfloop from="1" to="#arrayLen( dp )#" step="1" index="inx"> #dp[inx]# </cfloop> </cfoutput> Avoid using multiple <cfoutput> blocks as it is confusing and also tends to be slower than just having a single block.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > passing object referance (?) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|