Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array Functions - Any help is appreciated.

Status
Not open for further replies.

iao

Programmer
Feb 23, 2001
111
US
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=&quot;qMatrix&quot; DATASOURCE=&quot;etcetra&quot;>
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=&quot;qMatrix&quot;>
<cfset aMatrix[CurrentRow][1]=&quot;#DecimalFormat(qMatrix.TestHours)#&quot;>
<cfset aMatrix[CurrentRow][2]=&quot;#DollarFormat(qMatrix.TestAmount)#&quot;>
</cfloop>

<cfset total_records=qMatrix.RecordCount>

<cfloop index=&quot;Counter&quot; from=&quot;1&quot; to=&quot;#total_records#&quot;>
<cfoutput>
#aMatrix[Counter][1]#
</cfoutput>
</cfloop>
<br>
<cfloop index=&quot;Counter&quot; from=&quot;1&quot; to=&quot;#total_records#&quot;>
<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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top