SunQuest
           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:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old August 31st, 2004, 11:06 AM
babygodzilla babygodzilla is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 197 babygodzilla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 28 m 35 sec
Reputation Power: 5
skipping an array index

ok so i have 2 variables which are associated with each other: Name and UserID

i want to create an array using the UserID as the key and Name as the value. UserID doesn't necessarily start at 1, it can be like 132, 5353, and so on. I just tried populating the array with key 2521 and value "Me"

users[2521] = "Me"

but apparently this took forever because before Coldfusion could populate element 2521, it populated every element BEFORE 2521. So it populated 2521 ELEMENTS, which took damn near a minute. Is there a way to just populate a certain element without having to populate the elements before it?

Thanks!

Reply With Quote
  #2  
Old August 31st, 2004, 12:03 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
First, no, it's not possible to force CF to skip the other array elements. Second, you don't want to do this with an array. Array positions aren't meant to have "meaning", like to represent an id key. Use a structure:

<cfset myStruct = structNew() />
<cfset myStruct["2351"] = "me" />
<cfoutput>#myStruct.2351#</cfoutput>

Third, if it takes your server a minute to execute these line of code:

<cfset myArray = arrayNew(1) />
<cfset myArray[2351] = "me" />

Then something is wrong with your server. That took my local machine 4 milliseconds.
__________________
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 > skipping an array index


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