Skip to main content
Inspiring
May 9, 2008
Question

listcontains problem

  • May 9, 2008
  • 3 replies
  • 694 views
Hi,

I have a list (6,7,8,9,10,11) when I try and use listcontains to find the number 1, it picks out 11 when I want it to find the actual number 1.

Can anyone please help?

Thankyou
    This topic has been closed for replies.

    3 replies

    Inspiring
    May 9, 2008
    In a situation like this, the first thing to do is check the documentation. Determine if you are using the function correctly and if the function actually does what you need it to do. If it is not the right function to use, see what other List functions are available.
    http://livedocs.adobe.com/coldfusion/7/htmldocs/00000364.htm#1099435

    In the documentation it says ListContains "Determines the index of the first list element that contains a specified substring". So it would match "11", "112", "192637", etcetera. Clearly this is not the correct function for your needs. To find a whole element, use something like ListFind or ListFindNoCase.
    Inspiring
    May 9, 2008
    I agree, but the livedocs can be slows a moleasses which is frustrating, and doesn't have a proper search. I recommend downloading the PDFs and just putting shortcuts in your toolbar (at least to the reference file) or some other useful place where they can be pulled up at any time.

    http://www.adobe.com/support/documentation/en/coldfusion/
    Inspiring
    May 9, 2008
    quote:

    Originally posted by: danielmroberts
    I agree, but the livedocs can be slows a moleasses which is frustrating, and doesn't have a proper search. I recommend downloading the PDFs and just putting shortcuts in your toolbar (at least to the reference file) or some other useful place where they can be pulled up at any time.

    http://www.adobe.com/support/documentation/en/coldfusion/

    I use google.
    Inspiring
    May 9, 2008
    Mattastic wrote:
    > Hi,
    >
    > I have a list (6,7,8,9,10,11) when I try and use listcontains to find the number 1, it picks out 11 when I want it to find the actual number 1.
    >
    > Can anyone please help?
    >
    > Thankyou


    listContains() searches a list for a string fragment which may be part
    of an item.

    listFind() searches a list for an entire item.
    Inspiring
    May 9, 2008
    check out the listFind() function