Solved

Coldfusion Limit result from array

Posted on 2004-10-13
5
339 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
  • 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
The purpose of this video is to demonstrate how to connect a WordPress website to Google Analytics. This will be demonstrated using a Windows 8 PC Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php :…
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…

770 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