Coldfusion ArrayLen() Problem

Posted on 2004-10-21
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
    LVL 11

    Accepted Solution

    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

    Thanks so much for the speedy response!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
    Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
    The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
    The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…

    933 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now