• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

how to use list function in CF

Explorer ,
Jun 20, 2013 Jun 20, 2013

Copy link to clipboard

Copied

I have a file name as below :

2009 Master Calendar  (4.2.09).xls

Now how to use list funtions ie.listfirst or listlast to display the file name alone without the file ext.

ie,.2009 Master Calendar  (4.2.09)


Views

699

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 20, 2013 Jun 20, 2013

Copy link to clipboard

Copied

Are the docs somehow unclear?  You did read the docs, right?

http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7b62.html

What did you try, and in what way did it not work?

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 20, 2013 Jun 20, 2013

Copy link to clipboard

Copied

I used it as

<cfset filename=listfirst(#dirsOnly.Name#,'.')>

But i got the output as

2009 Master Calendar  (4

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 20, 2013 Jun 20, 2013

Copy link to clipboard

Copied

But you can see why that's happening, right? That *is* the first element of a dot-separated list, innit? So what you probably need to do is to revise your thinking slightly, and approach it from "how do I get rid of the last element of a list" (the file extension is the last element of a dot-delimited list.

How do you delete stuff from a list?

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 20, 2013 Jun 20, 2013

Copy link to clipboard

Copied

<cfset a = "2009 Master Calendar  (4.2.09).xls">

<cfset b = len(listlast(a,'.'))>

<cfset c = left(a,len(a) - b - 1)>

<cfoutput>#c#</cfoutput>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 20, 2013 Jun 20, 2013

Copy link to clipboard

Copied

LATEST

That's a lot more work that it needs to be. One can use listDeleteAt() to drop the last item from the list.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation