I am having a load of trouble with 2 dimensional arrays and more importantly, using array functions.
The problem I am having is simple, I can't use array functions (ArraySum, ArrayAvg) on any array that is 2 dimensional. If I can get is to pass without an error, the function does not return the value that I think is correct.
For example, here is a small piece of code:
<CFQUERY NAME="qMatrix" DATASOURCE="etcetra">
SELECT FN.TC_TIME.WORK_DATE, Sum(FN.TC_TIME.HOURS) as TestHours, Sum(FN.TC_TIME.AMOUNT) as TestAmount
FROM FN.TC_TIME, FN.TC_LINES
WHERE FN.TC_TIME.LINE_ID = FN.TC_LINES.LINE_ID AND
(FN.TC_TIME.EMP_NO = '5559') AND (FN.TC_LINES.PERIOD_DATE = '16-Feb-2001')
GROUP BY FN.TC_TIME.WORK_DATE
</CFQUERY>
<cfset aMatrix = ArrayNew(2)>
<cfloop query="qMatrix">
<cfset aMatrix[CurrentRow][1]="#DecimalFormat(qMatrix.TestHours)#">
<cfset aMatrix[CurrentRow][2]="#DollarFormat(qMatrix.TestAmount)#">
</cfloop>
<cfset total_records=qMatrix.RecordCount>
<cfloop index="Counter" from="1" to="#total_records#">
<cfoutput>
#aMatrix[Counter][1]#
</cfoutput>
</cfloop>
<br>
<cfloop index="Counter" from="1" to="#total_records#">
<cfoutput>
#aMatrix[Counter][2]#
</cfoutput>
</cfloop>
This returns a 2dimensional array just fine. But, whenever I try to use functions, I can't get it to work properly. For example, if I use the ArraySum function
(<cfoutput>#ArraySum(aMatrix[Counter])#</cfoutput><br>)
I get 2.12452568918E-314. It should be more like 72.
Any ideas on what I can do to make it work.
The problem I am having is simple, I can't use array functions (ArraySum, ArrayAvg) on any array that is 2 dimensional. If I can get is to pass without an error, the function does not return the value that I think is correct.
For example, here is a small piece of code:
<CFQUERY NAME="qMatrix" DATASOURCE="etcetra">
SELECT FN.TC_TIME.WORK_DATE, Sum(FN.TC_TIME.HOURS) as TestHours, Sum(FN.TC_TIME.AMOUNT) as TestAmount
FROM FN.TC_TIME, FN.TC_LINES
WHERE FN.TC_TIME.LINE_ID = FN.TC_LINES.LINE_ID AND
(FN.TC_TIME.EMP_NO = '5559') AND (FN.TC_LINES.PERIOD_DATE = '16-Feb-2001')
GROUP BY FN.TC_TIME.WORK_DATE
</CFQUERY>
<cfset aMatrix = ArrayNew(2)>
<cfloop query="qMatrix">
<cfset aMatrix[CurrentRow][1]="#DecimalFormat(qMatrix.TestHours)#">
<cfset aMatrix[CurrentRow][2]="#DollarFormat(qMatrix.TestAmount)#">
</cfloop>
<cfset total_records=qMatrix.RecordCount>
<cfloop index="Counter" from="1" to="#total_records#">
<cfoutput>
#aMatrix[Counter][1]#
</cfoutput>
</cfloop>
<br>
<cfloop index="Counter" from="1" to="#total_records#">
<cfoutput>
#aMatrix[Counter][2]#
</cfoutput>
</cfloop>
This returns a 2dimensional array just fine. But, whenever I try to use functions, I can't get it to work properly. For example, if I use the ArraySum function
(<cfoutput>#ArraySum(aMatrix[Counter])#</cfoutput><br>)
I get 2.12452568918E-314. It should be more like 72.
Any ideas on what I can do to make it work.