Solved

Coldfusion Limit result from array

Posted on 2004-10-13
5
335 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
Comment Utility
<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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
NP

Glad I could help
0

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

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Dynamically highly text on a webpage 9 97
SCCM vs Windows server 5 70
Webserver access problem 5 61
Systems talking to each other 5 107
This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

763 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

13 Experts available now in Live!

Get 1:1 Help Now