>- see footer for list info -<
cflib is your friend:

ListLeft: http://www.cflib.org/udf.cfm?ID=410
ListRight: http://www.cflib.org/udf.cfm?ID=411


Duncan Cumming
New Media Developer
Customer Relations Management / Education
Fife Council
08451 55 55 55, extension 44 44 65

My number changed on 23rd July to 08451 55 55 55, extension 44 44 65
Many other council numbers changed on that date - please go to 
www.fifedirect.org.uk and click on the 'Big Number Change' link for details.

>>> [EMAIL PROTECTED] 03/10/2007 14:17 >>>
>- see footer for list info -<
Hi,

 

I have a list with a number of elements, for example I might have 10
elements in my list (filled with numbers 1 to 10). What I'd like to do
is get the last 3 elements from my list, maybe I'd like to get the first
3 or the last 5, etc.

 

Ideally I'd do the following to get the last 3 elements in my list:

 

myList = "1,2,3,4,5,6,7,8,9,10";

Right(myList, 3);

 

This doesn't work as ColdFusion treats a List as a String, so the above
will only return the last 3 characters in my list (",10").

 

I could do the following to get what I need:

 

<cfset myList = "1,2,3,4,5,6,7,8,9,10">

<cfset myNewList = "">

 

<cfloop from="0" to="2" index="idx">

            <cfset myNewList = ListAppend(myNewList, ListGetAt(myList,
ListLen(myList) - idx))>

</cfloop>

 

But I see this looping and having to work out the correct from/to values
a bit messy, there must be an even simpler way, anybody have any tips
for me?

 

Thanks, 

Chris W

_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo 

--
CFDeveloper Sponsors:-
>- cfdeveloper Hosting provided by www.cfmxhosting.co.uk -<
>- Lists hosted by www.Gradwell.com -<
>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<


**********************************************************************
This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed and 
should not be disclosed to any other party. 
If you have received this email in error please notify your system manager and 
the sender of this message.

This email message has been swept for the presence of computer viruses but no 
guarantee is given that this e-mail message and any attachments are free from 
viruses.

Fife Council reserves the right to monitor the content of all incoming and 
outgoing email.

Fife Council
************************************************

_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo

--
CFDeveloper Sponsors:-
>- cfdeveloper Hosting provided by www.cfmxhosting.co.uk -<
>- Lists hosted by www.Gradwell.com -<
>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<

Reply via email to