Copy link to clipboard
Copied
Hello,
On CF9, I am having no issues. Currently, I am testing on a new web server with CF11 update 10. The error I am receiving is:
0 is not greater than zero or less than or equal to 0.The range passed to ArraySet must begin with a number greater than zero and less than or equal to the second number.
Here is a snippet of my code (not sure if you will need more than that). The bolded code is where it is saying it is erroring out on and I believe is where I need to make a change. I am more or less looking for more ideas on what to check or if something has changed since CF9 that I have not read on. I tried referencing Re: Crosstab - array error for my issue but still couldn't find a good solution. I was told to create a new thread.
---
<cfset bucketlist = ValueList(crosstabcolumns2.ts_desc)>
<cfset bucketheaders = ListToArray(bucketlist)>
<cfset b = ArrayLen(bucketheaders)>
<cfset bucketarray = ArrayNew(1)>
<cfset bucketTotal = ArrayNew(1)>
<cfset temp = arrayset(bucketTotal,1,b,"0")>
<cfoutput query="summedresultsNewOld" group="classcode">
<table border="1" cellpadding="5">
<tr><th width="225">MAIN CAMPUS</th>
<cfloop index="i" From="1" to="#b#">
<th>#bucketheaders#</th>
</cfloop>
<th width="125">TOTALS</th>
</tr>
<cfoutput group="ts_type" >
<tr><th>#ts_type#</th>
<cfset temp = arrayset(bucketarray,1,b,"0")>
<cfoutput>
<cfset i = listfind(bucketlist, trim(summedresultsNewOld.ts_desc))>
<cfset temp = ArraySet(bucketarray, i, i, summedresultsNewOld.headcount)>
<cfset temp = ArraySet(BucketTotal,i, i, (BucketTotal + summedresultsNewOld.headcount))>
</cfoutput>
<cfset rowtotal = 0>
<cfloop index="j" from="1" to="#b#">
<cfset rowtotal = #rowtotal# + #bucketarray
<td width="125">#bucketarray
</cfloop>
<td>#rowtotal#</td>
</tr>
</cfoutput>
<tr>
<th bgcolor="##999999">TOTALS</th>
<cfloop index="j" from="1" to="#b#">
<td bgcolor="##999999">#BucketTotal
</cfloop>
<td bgcolor="##999999">#ArraySum(BucketTotal)#</td>
</tr>
</table>
</cfoutput>
---
This is the result of what it should look like (currently in CF9). Any help is appreciated!
Off the top of my head, you are setting i to ListFind(), which returns 0 when the item is not found in the list.
If you are SURE that the item is in the list, try using ListFindNoCase() - it could be a case sensitive issue.
HTH,
^_^
PS: Check to make sure that everything is trim()'d, and that the list items do not have any whitespaces. That can also cause an item to not be found.
Copy link to clipboard
Copied
Off the top of my head, you are setting i to ListFind(), which returns 0 when the item is not found in the list.
If you are SURE that the item is in the list, try using ListFindNoCase() - it could be a case sensitive issue.
HTH,
^_^
PS: Check to make sure that everything is trim()'d, and that the list items do not have any whitespaces. That can also cause an item to not be found.
Copy link to clipboard
Copied
I first tried replacing ListFind with ListFindNoCase but got no results (same errors). Then when I read your response about trim(), it triggered in my head that might be the issue. By replacing trim() in:
<cfset i = listfind(bucketlist, trim(summedresultsNewOld.ts_desc))>
<cfset temp = ArraySet(bucketarray, i, i, summedresultsNewOld.headcount)>
<cfset temp = ArraySet(BucketTotal,i, i, (BucketTotal + summedresultsNewOld.headcount))>
</cfoutput>
It fixed my issue. Not really sure why trim was used beforehand or why it works in CF9 versus CF11. I might retrace my steps and see eventually why that was used. Thanks for the help!
Copy link to clipboard
Copied
Glad to hear that you got it working, and thank you for marking my answer correct, in case anyone else has the same issue.
V/r,
^_^