4 Replies Latest reply: Jan 2, 2014 3:36 PM by Srikanth P RSS

    compare value to list error

    Boris Kacevich

      I'm trying to compare a variable to match a list, something like 'IN' in SQL.

       

      How do I create a variable containing  a list, and how to I compare a certain variable with 1 string to the list variable and check whether it is in the list.


      is this correct?


      let vTest = '1;2;3';

      let vTemp= '1';


      if match ('$(vTemp)','$(vTest)')  then




      regards,


      Boris

        • Re: compare value to list error
          Stefan Wühl

          Your list of values in the match functions needs to be delimited by a comma, and you need to take care of quotation when comparing strings.

           

          So this should work:

           

          Set vTest = "'Aa','B','C'";

          Set vTemp= "'Aa'";

           

          IF Match ($(vTemp),$(vTest))  then

            TRACE Success;

          ELSE

            TRACE NOSUCCESS;

          ENDIF;

          • Re: compare value to list error
            Jonathan Dienst

            Hi

             

            You can do this with

             

                 If index(vTest, vTemp) > 0 Then

                 or

                 If index(';' & vTest & ';', ';' & vTemp & ';') > 0 Then     //(exact matches)

             

            But if you need to use match, then:

             

            let vTest = '1;2;3';

            let vTemp = '1';

             

            Let vList = chr(39) & Replace(vTest, ';', chr(39) & ',' & chr(39)) & chr(39);

            If Match(vTemp, $(vList)) Then

             

            Note that there are NO quotes in the Match expression, they have been added beforehand (chr(39))

             

            HTH

            Jonathan

            • Re: compare value to list error
              Boris Kacevich

              The list is created by a load script in which I add to this list ID numbers from a table.

               

               

                TempList:

                LOAD concat(RUN_ID,',') as RUN_IDList

                from 'c:\DATA_TABLE.qvd' (qvd)

                let vRunIdList=peek('RUN_IDList',0,TempList);

               

              Any recommendations to this list creation? and to the match function?

               

              Thanks,

              • Re: compare value to list error
                Srikanth P

                Try with WildMatch function like below:

                 

                let vTest = '1;2;3';

                let vTemp= '1';


                if WildMatch('$(vTemp)','$(vTest)')  then