3 Replies Latest reply on Jan 17, 2007 1:19 AM by the real POTMO

    check if an element of a list exists

    Level 7
      Hi,

      here is a basic thing, how make an if-condition to check wheater an
      listelement exists or not.

      When I try:

      getat(gPicMemList, Num)

      and index Num in the list does not exist I will get an error message.

      Any quick help?
        • 1. Re: check if an element of a list exists
          Level 7
          theList = [4, 5, 2, 34]
          if theList.getOne (5) <> 0 then
          -- do something when element exists
          end if

          --
          Craig Wollman
          Lingo Specialist
          Word of Mouth Productions
          212-928-9581

          www.wordofmouthpros.com
          "castten" <invalid@invalid.invalid> wrote in message
          news:eoj1gk$25a$1@forums.macromedia.com...
          > Hi,
          >
          > here is a basic thing, how make an if-condition to check wheater an
          > listelement exists or not.
          >
          > When I try:
          >
          > getat(gPicMemList, Num)
          >
          > and index Num in the list does not exist I will get an error message.
          >
          > Any quick help?


          • 2. Re: check if an element of a list exists
            Level 7
            ...where 5 is an element you're checking for (num)

            --
            Craig Wollman
            Lingo Specialist
            Word of Mouth Productions
            212-928-9581

            www.wordofmouthpros.com
            "forum.macromedia.com" <lingoboy@wordofmo.com> wrote in message
            news:eoj9b3$bk6$1@forums.macromedia.com...
            > theList = [4, 5, 2, 34]
            > if theList.getOne (5) <> 0 then
            > -- do something when element exists
            > end if
            >
            > --
            > Craig Wollman
            > Lingo Specialist
            > Word of Mouth Productions
            > 212-928-9581
            >
            > www.wordofmouthpros.com
            > "castten" <invalid@invalid.invalid> wrote in message
            > news:eoj1gk$25a$1@forums.macromedia.com...
            >> Hi,
            >>
            >> here is a basic thing, how make an if-condition to check wheater an
            >> listelement exists or not.
            >>
            >> When I try:
            >>
            >> getat(gPicMemList, Num)
            >>
            >> and index Num in the list does not exist I will get an error message.
            >>
            >> Any quick help?
            >
            >


            • 3. Re: check if an element of a list exists
              the real POTMO Level 1
              or if youre using propLists

              tList = [#frank: 3, #benny: 5, #joe: 9, #seb: 4]
              if not voidp(tList[#benny]) then
              put tList[#benny]
              end if

              You cant check that with the dot syntax just by doing this
              tList = [#frank: 3, #benny: 5, #joe: 9, #seb: 4]
              if not voidp(tList.benny) then
              put tList.benny
              end if
              youll get a script error then so use the first example.

              remember that if you use strings as indexkeys they are case sensitive (only thing in lingo that is as far as I know).