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:
  #1  
Old August 23rd, 2004, 11:07 AM
wdn2000's Avatar
wdn2000 wdn2000 is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Apr 2000
Posts: 1,058 wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 Days 20 h 56 m 43 sec
Reputation Power: 16
Position 0 in an array?

Am I missing something or does CF not allow a position 0 in an array?

Here's a snippet of my code:
Code:
<cfset choices = ArrayNew(1)>
<cfset choices[0] = "Select">
<cfset choices[1] = "Strongly Agree">
<cfset choices[2] = "Agree">
<cfset choices[3] = "Disagree">
<cfset choices[4] = "Strongly Disagree">
<cfset choices[5] = "No Opinion/Not Applicable">


And here's the error I'm getting:
The element at position 0 of array variable "CHOICES" cannot be found.

If I remove: <cfset choices[0] = "Select">
it executes perfectly.

Any help appreciated,
wdn2k

Reply With Quote
  #2  
Old August 23rd, 2004, 12:12 PM
globeuser globeuser is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 10 globeuser User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
the first element in an array always starts with the numeral one. Most other languages start with zero. I personally think it’s much more intuitive to start with one instead of zero, but others would disagree.

Reply With Quote
  #3  
Old August 23rd, 2004, 12:20 PM
wdn2000's Avatar
wdn2000 wdn2000 is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Apr 2000
Posts: 1,058 wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 Days 20 h 56 m 43 sec
Reputation Power: 16
Quote:
Originally Posted by globeuser
the first element in an array always starts with the numeral one. Most other languages start with zero. I personally think it’s much more intuitive to start with one instead of zero, but others would disagree.


That's just weird.

To me, more intuitive would be to allow any integer and let the programmer decide what would be more useful for their application.

Reply With Quote
  #4  
Old August 23rd, 2004, 12:38 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,700 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 17 h 45 m 21 sec
Reputation Power: 53
CF deviates from other languages in this regard. Arrays always start with 1. Yes, it's wierd. But really, it's not very hard to cope with once you know it.
__________________
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
  #5  
Old August 23rd, 2004, 03:21 PM
globeuser globeuser is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 10 globeuser User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hmmm interesting.. it would be interesting if they could do that because internally (addressing), they are stored pretty much the same way.. then again, it won't be consistent and other people looking at anotehr person's code may be confused...

as the saying goes, just because we can do it, does not mean we have to do it.

come to think of it, why was the reason why arrays start at 0 in the first place. My guess it's because its the origin.. so it starts off at 0,0 say...



Quote:
Originally Posted by wdn2000
That's just weird.

To me, more intuitive would be to allow any integer and let the programmer decide what would be more useful for their application.

Reply With Quote
  #6  
Old August 23rd, 2004, 07:03 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,700 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 17 h 45 m 21 sec
Reputation Power: 53
Simply because it makes far more sense for the first element in an array to be element number 1. That's the only reason.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Position 0 in an array?


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 6 hosted by Hostway
Stay green...Green IT