ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old December 14th, 2004, 03:29 PM
FALCONSEYE FALCONSEYE is offline
Permanently Banned
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 377 FALCONSEYE Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 Day 16 h 57 m 14 sec
Warnings Level: 15
Number of bans: 1
Reputation Power: 0
Question passing object referance (?)

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

Reply With Quote
  #2  
Old December 14th, 2004, 03:35 PM
bocmaxima's Avatar
bocmaxima bocmaxima is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Aug 2004
Location: Tucson, Sonora
Posts: 1,322 bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 17 h 46 m 5 sec
Reputation Power: 22
Send a message via AIM to bocmaxima
<cfset crap = 'dp'&inx>

is interpreted as a string

Use this:
<cfset crap = Evaluate("dp" & inx)>

Reply With Quote
  #3  
Old December 14th, 2004, 04:24 PM
FALCONSEYE FALCONSEYE is offline
Permanently Banned
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 377 FALCONSEYE Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 Day 16 h 57 m 14 sec
Warnings Level: 15
Number of bans: 1
Reputation Power: 0
thanks bocmaxima

Reply With Quote
  #4  
Old December 14th, 2004, 05:09 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > passing object referance (?)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway