>- see footer for list info -<
<cfset array[1] = "foo">
<cfset array[3] = "bar">

ArrayLen(array) = 2, but array[2] doesn't exist.  It's a pain in the butt, 
because obvious checks like IsDefined etc don't really work.  You need to use a 
try-catch around it, and just do nothing if it throws an error:

<cfloop from="1" to="#arrayLen(myArray)#" index="i">
<cftry>
    <cfif myArray[i] = 'eat my shorts'>
        <!---- do stuff --->
    </cfif>
<cfcatch type="any"></cfcatch>
</cftry>
</cfif>

Duncan Cumming
New Media Developer
Customer Relations Management / Education
Fife Council
700 4105 / 01592 414105

>>> [EMAIL PROTECTED] 08/09/2006 12:01 >>>
>- see footer for list info -<
Hi guys, I'm getting an error I can't fathom. It's an index out of bounds
error while looping an array and it it only happens about 0.5% of the time,
seemingly randomly.

The code looks something like this:

<cfloop from="1" to="#arrayLen(myArray)#" index="i">
    <cfif myArray[i] = 'eat my shorts'>
        <!---- do stuff --->
    </cfif>
</cfif>

The index out of bounds error is occurring on the 'eat my shorts' line. How
might this be?

Dom
_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo 

--
CFDeveloper Sponsors:-
>- cfdeveloper Hosting provided by www.cfmxhosting.co.uk -<
>- Lists hosted by www.Gradwell.com -<
>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<


**********************************************************************
This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed and 
should not be disclosed to any other party. 
If you have received this email in error please notify your system manager and 
the sender of this message.

This email message has been swept for the presence of computer viruses but no 
guarantee is given that this e-mail message and any attachments are free from 
viruses.

Fife Council
Tel: 08451 55 00 00
************************************************

_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo

--
CFDeveloper Sponsors:-
>- cfdeveloper Hosting provided by www.cfmxhosting.co.uk -<
>- Lists hosted by www.Gradwell.com -<
>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<

Reply via email to