Note that there are some explanatory texts on larger screens.

plurals
  1. POInvalid index [0] for array. Index must be a positive integer
    primarykey
    data
    text
    <p>The following code worked in Adobe ColdFusion but since migrating to Railo gives me the following error:</p> <p><strong>Error Messages: Invalid index [0] for array. Index must be a positive integer (1, 2, 3, ...)</strong></p> <p>Error is on line starting: <strong>local.arrChartDataResult=addPercentageData(local.arrChartDataResult)</strong></p> <p>Any idea why this is the case?</p> <pre><code> &lt;cffunction name="getAverageChartData" hint="I return the data required to render an average chart." returntype="array" output="false"&gt; &lt;cfargument name="surveyList" hint="I am a record set of Surveys." required="true" type="query" /&gt; &lt;cfargument name="filter" hint="I am the optional filter which is to be applied to all results." required="false" default="" type="string" /&gt; &lt;cfset var local=structNew() /&gt; &lt;cfset var rstChartData="" /&gt; &lt;cfset var rstChartDataTotal="" /&gt; &lt;cfset var rstCombinedChartData=queryNew("itemColumn,valueColumn,label","varchar,integer,varchar") /&gt; &lt;cfset local.objQuestion=objQuestionService.get(arguments.surveyList.question_ID[1]) /&gt; &lt;cfset local.intQuestionTypeID = local.objQuestion.getTypeID() /&gt; &lt;cfset local.strSubQuestionList=local.objQuestion.getAnswer() /&gt; &lt;cfset local.strPossibleAnswerList=local.objQuestion.getPossibleAnswer() /&gt; &lt;cfset local.arrChartDataResult=arrayNew(1) /&gt; &lt;!--- loop over each school's survey ---&gt; &lt;cfloop query="arguments.surveyList"&gt; &lt;cfset local.arrChartData = getChartData(arguments.surveyList.survey_id, arguments.surveyList.question_id, arguments.filter) /&gt; &lt;!--- loop over each sub question and append (union) it to a running total ---&gt; &lt;cfloop array="#local.arrChartData#" index="rstChartData"&gt; &lt;cfquery name="rstCombinedChartData" dbtype="query"&gt; SELECT itemColumn ,valueColumn ,label FROM rstCombinedChartData UNION ALL SELECT itemColumn ,CAST(valueColumn AS INTEGER) AS valueColumn ,label FROM rstChartData &lt;/cfquery&gt; &lt;/cfloop&gt; &lt;/cfloop&gt; &lt;cfif local.intQuestionTypeID EQ 17&gt; &lt;cfquery name="rstChartDataTotal" dbtype="query"&gt; SELECT itemColumn ,AVG(valueColumn) AS valueColumn ,label FROM rstCombinedChartData GROUP BY label ,itemColumn ORDER BY label DESC &lt;!---,itemColumn DESC---&gt; &lt;/cfquery&gt; &lt;cfelse&gt; &lt;!--- get the totals for each itemColumn ---&gt; &lt;cfquery name="rstChartDataTotal" dbtype="query"&gt; SELECT itemColumn ,SUM(valueColumn) AS valueColumn ,label FROM rstCombinedChartData GROUP BY label ,itemColumn ORDER BY label DESC ,itemColumn DESC &lt;/cfquery&gt; &lt;/cfif&gt; &lt;!--- add sort order column to query and populate it with the order in which the sub questions are asked ---&gt; &lt;cfset rstChartDataTotal=orderByQuestion(rstChartDataTotal, local.strSubQuestionList) /&gt; &lt;!--- if this is a one-dimensional question ---&gt; &lt;cfif arrayLen(local.arrChartData) EQ 1&gt; &lt;cfset local.arrChartDataResult[1]=addPercentageData_Old(rstChartDataTotal) /&gt; &lt;cfelse&gt; &lt;cfset arrayResize(local.arrChartDataResult, listLen(local.strPossibleAnswerList)) /&gt; &lt;cfoutput query="rstChartDataTotal" group="label"&gt; &lt;cfset local.intPositionInArray=listFindNoCase(local.strPossibleAnswerList, rstChartDataTotal.label, True) /&gt; &lt;cfoutput&gt; &lt;cfquery name="local.rstChartData" dbtype="query"&gt; SELECT itemColumn ,valueColumn ,label ,sortOrder FROM rstChartDataTotal WHERE label = '#rstChartDataTotal.label#' ORDER BY sortOrder &lt;/cfquery&gt; &lt;/cfoutput&gt; &lt;cfset local.arrChartDataResult[local.intPositionInArray]=local.rstChartData&gt; &lt;/cfoutput&gt; &lt;cfset local.arrChartDataResult=addPercentageData(local.arrChartDataResult) /&gt; &lt;/cfif&gt; &lt;cfreturn local.arrChartDataResult /&gt; &lt;/cffunction&gt; </code></pre> <p>Full Error:</p> <pre><code>Application Execution Exception Error Type: expression : 0 Error Messages: Invalid index [0] for array. Index must be a positive integer (1, 2, 3, ...) Template: /srv/www/testapp/admin/model/response/ResponseService.cfc Current Event: pdf.createPDF Current Layout: N/A Current View: N/A Bug Date: 07/29/2013 10:53:19 AM Coldfusion ID: CFID=c07b7b4e-d79e-4688-950d-20f0192a27ca ; CFToken=0 ; JSessionID=4A3B1BC689B4C438DAAF1088A42A6481_c07b7b4e-d79e-4688-950d-20f0192a27ca_0 Template Path : /srv/www/testapp/admin/index.cfm Path Info : /pdf/createPDF Host &amp; Server: management.testapp.co.uk:8888 ip-172-31-24-53 Query String: Referrer: http://management.testapp.co.uk:8888/index.cfm/home?fwreinit=1 Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:22.0) Gecko/20100101 Firefox/22.0 Invalid index [0] for array. Index must be a positive integer (1, 2, 3, ...) at railo.runtime.type.ArrayImpl.setE(ArrayImpl.java:226):226 at railo.runtime.type.ArrayImpl.set(ArrayImpl.java:205):205 at railo.runtime.type.util.ArraySupport.set(ArraySupport.java:360):360 at railo.runtime.util.VariableUtilImpl.set(VariableUtilImpl.java:437):437 at railo.runtime.PageContextImpl.set(PageContextImpl.java:1266):1266 at model.response.responseservice_cfc$cf._1(/srv/www/testapp/admin/model/response/ResponseService.cfc:268):268 at model.response.responseservice_cfc$cf.udfCall(/srv/www/testapp/admin/model/response/ResponseService.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103 at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371 at railo.runtime.type.UDFImpl.call(UDFImpl.java:284):284 at railo.runtime.ComponentImpl._call(ComponentImpl.java:607):607 at railo.runtime.ComponentImpl._call(ComponentImpl.java:490):490 at railo.runtime.ComponentImpl.call(ComponentImpl.java:1781):1781 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:723):723 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1506):1506 at handlers.pdf_cfc$cf.udfCall(/srv/www/testapp/admin/handlers/pdf.cfc:289):289 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103 at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371 at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:275):275 at railo.runtime.ComponentImpl._call(ComponentImpl.java:608):608 at railo.runtime.ComponentImpl._call(ComponentImpl.java:490):490 at railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1796):1796 at railo.runtime.tag.Invoke.doComponent(Invoke.java:209):209 at railo.runtime.tag.Invoke.doEndTag(Invoke.java:182):182 at system.web.controller_cfc$cf._6(/srv/www/testapp/admin/framework/coldbox_standalone_3.0.0.RC1/system/web/Controller.cfc:662):662 at system.web.controller_cfc$cf.udfCall(/srv/www/testapp/admin/framework/coldbox_standalone_3.0.0.RC1/system/web/Controller.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103 at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371 at railo.runtime.type.UDFImpl.call(UDFImpl.java:284):284 at railo.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:775):775 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:723):723 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1506):1506 at system.web.controller_cfc$cf._5(/srv/www/testapp/admin/framework/coldbox_standalone_3.0.0.RC1/system/web/Controller.cfc:553):553 at system.web.controller_cfc$cf.udfCall(/srv/www/testapp/admin/framework/coldbox_standalone_3.0.0.RC1/system/web/Controller.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103 at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371 at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:275):275 at railo.runtime.ComponentImpl._call(ComponentImpl.java:608):608 at railo.runtime.ComponentImpl._call(ComponentImpl.java:490):490 at railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1800):1800 at railo.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:749):749 at railo.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1521):1521 at system.coldbox_cfc$cf._1(/srv/www/testapp/admin/framework/coldbox_standalone_3.0.0.RC1/system/Coldbox.cfc:226):226 at system.coldbox_cfc$cf.udfCall(/srv/www/testapp/admin/framework/coldbox_standalone_3.0.0.RC1/system/Coldbox.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103 at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371 at railo.runtime.type.UDFImpl.call(UDFImpl.java:284):284 at railo.runtime.ComponentImpl._call(ComponentImpl.java:607):607 at railo.runtime.ComponentImpl._call(ComponentImpl.java:490):490 at railo.runtime.ComponentImpl.call(ComponentImpl.java:1781):1781 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:723):723 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1506):1506 at application_cfc$cf.udfCall(/srv/www/rudifferent/admin/Application.cfc:54):54 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103 at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371 at railo.runtime.type.UDFImpl.call(UDFImpl.java:284):284 at railo.runtime.ComponentImpl._call(ComponentImpl.java:607):607 at railo.runtime.ComponentImpl._call(ComponentImpl.java:490):490 at railo.runtime.ComponentImpl.call(ComponentImpl.java:1781):1781 at railo.runtime.listener.ModernAppListener.call(ModernAppListener.java:346):346 at railo.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:107):107 at railo.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:18):18 at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2255):2255 at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2222):2222 at railo.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:315):315 at railo.loader.servlet.CFMLServlet.service(CFMLServlet.java:29):29 at javax.servlet.http.HttpServlet.service(HttpServlet.java:728):728 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305):305 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210):210 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222):222 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123):123 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472):472 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171):171 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99):99 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118):118 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407):407 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004):1004 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589):589 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312):312 at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source):-1 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source):-1 at java.lang.Thread.run(Unknown Source):-1 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload