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 October 17th, 2004, 12:11 PM
mikemac mikemac is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Greenville NC
Posts: 70 mikemac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 15 m 24 sec
Reputation Power: 4
Question Array output..element not found

When populating an array I get a element not fond error.
I get this error....
The element at position 3 of dimension 1, of array variable "NUMOFAWN," cannot be found.
The error occurred on line 70.

Here is the code...
<!---Put users entries in Arrays for easier data manipulation--->
<!---Outer loop iterates once per every #SESSION.NumOfAwnz#iterations of the inner loop--->
<CFLOOP from="1" to="#SESSION.NumberOfQuest#" index="i">
<!---Put all questions in quesList Array--->
<CFSET quesList=#form['question' & i]#>
<CFSET CorrAwnList=#form['correctAwn' & i]#>

<CFLOOP from="1" to="#SESSION.NumOfAwnz#" index="r">

<CFSET NumOfAwn[r]=#form['answer' & i & "." & r]#>

</CFLOOP>
</CFLOOP>

<!---Set a global variable for the array that outputs possible answers--->
<cfset y=1>
<!---Output users entries to confirm data b4 inserting in database--->
<CFLOOP from="1" to="#ArrayLen(quesList)#" index="o">
<CFOUTPUT>
<B>Question #o#:</B>#quesList[o]#<BR />
<B class="one">Correct Answer #o#:</B>#CorrAwnList[o]#<BR />
<B class="two">Possible answers for question #o#</B><BR />
</CFOUTPUT>
<CFLOOP from="1" to="#SESSION.NumOfAwnz#" index="s">
<CFOUTPUT>
<!---Line 70---> <B class="three">"#NumOfAwn[y]#"</B><BR />
<CFSET y=y+1>
</CFOUTPUT>
</CFLOOP>
</CFLOOP>

Reply With Quote
  #2  
Old October 17th, 2004, 05:28 PM
mikemac mikemac is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Greenville NC
Posts: 70 mikemac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 15 m 24 sec
Reputation Power: 4
?

Quote:
Originally Posted by mikemac
When populating an array I get a element not fond error.
I get this error....
The element at position 3 of dimension 1, of array variable "NUMOFAWN," cannot be found.
The error occurred on line 70.

Here is the code...
<!---Put users entries in Arrays for easier data manipulation--->
<!---Outer loop iterates once per every #SESSION.NumOfAwnz#iterations of the inner loop--->
<CFLOOP from="1" to="#SESSION.NumberOfQuest#" index="i">
<!---Put all questions in quesList Array--->
<CFSET quesList=#form['question' & i]#>
<CFSET CorrAwnList=#form['correctAwn' & i]#>

<CFLOOP from="1" to="#SESSION.NumOfAwnz#" index="r">

<CFSET NumOfAwn[r]=#form['answer' & i & "." & r]#>

</CFLOOP>
</CFLOOP>

<!---Set a global variable for the array that outputs possible answers--->
<cfset y=1>
<!---Output users entries to confirm data b4 inserting in database--->
<CFLOOP from="1" to="#ArrayLen(quesList)#" index="o">
<CFOUTPUT>
<B>Question #o#:</B>#quesList[o]#<BR />
<B class="one">Correct Answer #o#:</B>#CorrAwnList[o]#<BR />
<B class="two">Possible answers for question #o#</B><BR />
</CFOUTPUT>
<CFLOOP from="1" to="#SESSION.NumOfAwnz#" index="s">
<CFOUTPUT>
<!---Line 70---> <B class="three">"#NumOfAwn[y]#"</B><BR />
<CFSET y=y+1>
</CFOUTPUT>
</CFLOOP>
</CFLOOP>



??????? Any ideas,its like it stops accepting variables half way thru the loop????

Reply With Quote
  #3  
Old October 17th, 2004, 07:35 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
The problem is that your loop is going to #session.numOfAwnz# but your output is using #numOfAwn#. Apparantly, NumOfAwn doesn't have the same number of elements as the value in session.numOfAwnz, so you're referencing an array alement that isn't there. That's what the error is. Why not do something like this:

<CFOUTPUT>
<CFLOOP from="1" to="#arrayLen( NumOfAwn )#" index="thisElement">
<!---Line 70---> <B class="three">"#NumOfAwn[thisElement]#"</B><BR />
</CFLOOP>
</CFOUTPUT>
__________________
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 > Array output..element not found


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