home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Documentation / snippets / arraysum.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  1.1 KB  |  42 lines

  1. <!--- This example shows the use of ArraySum --->
  2. <HTML>
  3. <HEAD>
  4. <TITLE>ArraySum Example</TITLE>
  5. </HEAD>
  6.  
  7. <BODY>
  8. <H3>ArraySum Example</H3>
  9. <P>
  10. If this example doesn't run or returns 
  11. erroneous results, you may need to 
  12. either create the snippets collection
  13. (using the CFCOLLECTION example) or populate
  14. the snippets collection (using the CFINDEX example).
  15. <HR>
  16. <!--- create an array --->
  17. <CFSET myNumberArray = ArrayNew(1)>
  18. <!--- run a standard search --->
  19.  <CFSEARCH NAME="SearchSnippets"
  20.         COLLECTION="snippets"
  21.         TYPE="simple"
  22.         CRITERIA="Array*">
  23. <!--- set a temp variable --->
  24. <CFSET temp = 1>
  25. <!--- output the results of the search --->
  26. <CFOUTPUT QUERY="SearchSnippets">
  27.     <CFSET myNumberArray[temp] = score>
  28. <CFSET temp = temp + 1>
  29. </CFOUTPUT>
  30. <!--- use ArrayAvg to get the average score --->
  31. <P>The average score for your search on the term
  32. "Array*" in the collection "Snippets" is 
  33. <CFOUTPUT>
  34. #ArrayAvg(myNumberArray)# for
  35. #SearchSnippets.RecordCount# "hits"<BR>
  36. <P>The sum of the elements in the array is
  37. #ArraySum(myNumberArray)#
  38. </CFOUTPUT>
  39.  
  40. </BODY>
  41. </HTML>       
  42.