[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Coldfusion ArrayLen() Problem

Posted on 2004-10-21
Medium Priority
Last Modified: 2013-12-24
I have an array of a structure from which I am already successfully outputting the correct number of results (where Arr_TotalResults[i].SOURCE IS "Gemini", which is outputting 5 rows because only 5 elements EQ Gemini). I now need to get the array length MINUS those which do not have a structure key SOURCE IS "Gemini". I thought the code below would do this because it is already working on the output, however, it's giving me the full length of the array (which is 11) and still including those which do not match 'Gemini'. Please can someone tell me what I'm doing wrong here??

Many thanks,

<cfloop from="1" to="#arrayLen(Arr_TotalResults)#" index="i">
 <cfif Arr_TotalResults[i].SOURCE IS "Gemini">
  <cfset js_numBoth=arrayLen(Arr_TotalResults)>


Question by:mjacobs2929
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 11

Accepted Solution

hart earned 2000 total points
ID: 12369711
just do this

<cfset nGeminiCtr = 0>
<cfloop from="1" to="#arrayLen(Arr_TotalResults)#" index="i">
   <cfif Arr_TotalResults[i].SOURCE IS "Gemini">
     <cfset nGeminiCtr = IncrementValue(nGeminiCtr)>


For Gemini Total Count  EQ #nGeminiCtr#<br>
For The total Array Length - #ArrayLen(TotalResults)#<br>
For The count with out Gemini - #Evaluate(ArrayLen(TotalResults)-nGeminiCtr)#<br>


Author Comment

ID: 12369836
Thanks so much for the speedy response!

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question