Solved

Coldfusion Limit result from array

Posted on 2004-10-13
5
341 Views
Last Modified: 2013-12-20
I just want to grab the first FLTDURATION from array Arr_TotalResults. The following gives me a FLTDURATION for every item in the array. Is there a simple way to limit the result to just the first 'FLTDURATION' ?

<cfloop from="1" to="#arraylen(Arr_TotalResults)#" index="i"><cfoutput>(#Arr_TotalResults[i].FLTDURATION#)</cfoutput></cfloop>

Many thanks,
Michelle
0
Comment
Question by:mjacobs2929
[X]
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
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:kkhipple
ID: 12297173
<CFOUTPUT>
     #Arr_TotalResults[1]#
</CFOUTPUT>


This should give you the first value of the array. Now if FLT_DURATION is the first element, then this works. If FTL_DURATION is the fourth element in the array, then this works:

<CFOUTPUT>
     #Arr_TotalResults[4]#
</CFOUTPUT>


REFERENCE: http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/arrayStruct3.htm
0
 

Author Comment

by:mjacobs2929
ID: 12297983
Sorry, this is actually an array of a structure, so I can't rely on 'FLTDURATION' always being at position 4, or whatever. Is it possible to get just the first occurance of 'FLTDURATION' from an array containing a structure?
0
 
LVL 10

Accepted Solution

by:
Mause earned 500 total points
ID: 12299580
Hi

Width your code you loop over the array and get every FLTDURATION but this is not what you want!

To get the FLTDURATION of the first array position you do this:
<cfoutput>(#Arr_TotalResults[1].FLTDURATION#)</cfoutput>

Will this work for you?
or does every array value contains a different structure and you want the first FLTDURATION that is found in the array?

Let me know
Mause
0
 

Author Comment

by:mjacobs2929
ID: 12299646
Yep, that worked! Just wanted the first instance. I guess that shows how little I understand CF arrays or structures! :[
0
 
LVL 10

Expert Comment

by:Mause
ID: 12299654
NP

Glad I could help
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

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 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…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

751 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