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

how to use list function in CF

Explorer ,
Jun 20, 2013 Jun 20, 2013

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)


857
Translate
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

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

Translate
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

I used it as

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

But i got the output as

2009 Master Calendar  (4

Translate
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

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

Translate
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

<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>

Translate
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
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

Translate
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